-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
167 lines (141 loc) · 4.91 KB
/
.zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# _
# _______| |__ _ __ ___
# |_ / __| '_ \| '__/ __|
# _ / /\__ \ | | | | | (__
# (_)___|___/_| |_|_| \___|
# Welcome message, don't display in tmux
# fortune -s -n 150 | cowsay -W 38 -f cower | lolcat
[ -z "${TMUX}" ] && [ -f "$HOME/.scripts/hashbang.sh" ] && "$HOME/.scripts/hashbang.sh"
# [ -f "$HOME/.scripts/hashbang.sh" ] && "$HOME/.scripts/hashbang.sh"
# Enable colors and change prompt:
autoload -U colors && colors
# PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
# PS1="%B%{$fg[red]%}[%{$fg[magenta]%}%~%{$fg[red]%}]%{$fg[blue]%}$%{$reset_color%}%b "
# Preferences
setopt autocd # Automatically cd into typed directory
setopt APPEND_HISTORY # Don't overwrite history
setopt SHARE_HISTORY # History shared between shells
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
# History in cache directory:
HISTSIZE=8000
SAVEHIST=8000
HISTFILE=~/.config/zsh/history
# Variables
export PATH=$PATH:~/.local/bin
export PATH=$PATH:~/.scripts
export PATH=$PATH:~/.emacs.d/bin
export PATH=$PATH:~/.pyenv/bin
export PATH=$PATH:~/.npm-global/bin
export PATH=$PATH:~/.local/share/gem/ruby/3.0.0/bin
export PATH=$PATH:$HOME/npm/bin
export GOPATH=~/go
export GOPATH=$GOPATH~/golib
export SUDO_EDITOR=nvim
export EDITOR=nvim
export BROWSER=google-chrome-stable
# export FILEMANAGER=nautilus
# export RUST_BACKTRACE=full
export RUST_LOG=trace
export STARSHIP_CONFIG=~/.config/zsh/themes/starship/config.toml
# export TERM=xterm-256color
# Prevent double first character in commands
export LC_CTYPE=en_US.UTF-8
export XDG_RUNTIME_DIR=/run/user/1000
# Applications
export FZF_DEFAULT_OPTS="--layout=reverse --height=10"
# eval "$(pyenv init -)"
# eval "$(pyenv virtualenv-init -)"
# Basic auto/tab complete:
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files.
# Case insensitive completion
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
setopt no_list_ambiguous
# vi mode
bindkey -v
#export KEYTIMEOUT=1
# Use vim keys in tab complete menu:
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Use lf to switch directories
lfcd() {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
# Use nnn to switch directories
# nnncd() {
# # Block nesting of nnn in subshells
# if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
# echo "nnn is already running"
# return
# fi
# # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
# # To cd on quit only on ^G, remove the "export" as in:
# # NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# # NOTE: NNN_TMPFILE is fixed, should not be modified
# export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# # stty start undef
# # stty stop undef
# # stty lwrap undef
# # stty lnext undef
# nnn "$@"
# if [ -f "$NNN_TMPFILE" ]; then
# . "$NNN_TMPFILE"
# rm -f "$NNN_TMPFILE" > /dev/null
# fi
# }
# Custom ZSH Binds
bindkey -s '^o' 'lfcd\n'
bindkey 'jk' vi-cmd-mode
bindkey '^ ' autosuggest-accept
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line
# Load aliases if exist
[ -f "$HOME/.config/zsh/aliasrc" ] && source "$HOME/.config/zsh/aliasrc"
[ -f "$HOME/.config/zsh/zfunctions" ] && source "$HOME/.config/zsh/zfunctions"
# [ -f "$HOME/.config/zsh/zoxiderc" ] && source "$HOME/.config/zsh/zoxiderc"
# Load themes
eval "$(starship init zsh)"
# source "$HOME/.config/zsh/themes/spaceshiprc"
eval "$(zoxide init zsh)"
# source /usr/share/nvm/init-nvm.sh
# export PYENV_ROOT="$HOME/.pyenv"
# [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)"
# Load extensions ; should be last.
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null