-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc
280 lines (217 loc) · 5.79 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# vim:fdm=marker
# Global variables
export USE_PLUGINS=true # Load plugins or not
export {EDITOR,VISUAL}=nvim
export QT_QPA_PLATFORMTHEME=gtk2
export MANPAGER='nvim +Man!'
export BAT_THEME='NightOwl'
# Directory shortcuts
export D="$HOME/Scratch/Downloads"
# Load theme colors
source "$HOME/.theme.zsh"
# Required by some plugins
setopt promptsubst
# General configuration {{{
# History
HISTFILE="$HOME/.zsh_history"
HISTSIZE=100000
SAVEHIST=100000
setopt hist_expire_dups_first
setopt hist_find_no_dups
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_no_store
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_verify
setopt inc_append_history
setopt no_hist_allow_clobber
setopt no_hist_beep
# }}}
# zinit installation {{{
if [ "$USE_PLUGINS" = true ]; then
SKIP_COMPILE=false
if [[ ! -d "$HOME/.zinit" ]]; then
echo "Installing zinit..."
mkdir "$HOME/.zinit"
git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin"
# Create lock to compile zinit next time
touch "$HOME/.zinit-lock"
SKIP_COMPILE=true
fi
source "$HOME/.zinit/bin/zinit.zsh"
# Compile zinit if not compiled yet
if [[ "$SKIP_COMPILE" == false ]] \
&& [[ -f "$HOME/.zinit-lock" ]]; then
echo "Compiling zinit..."
zinit self-update
rm "$HOME/.zinit-lock"
fi
fi
# }}}
# zinit plugins {{{
if [[ "$USE_PLUGINS" = true ]]; then
if [[ -f "$HOME/.zinit.zsh" ]]; then
source "$HOME/.zinit.zsh"
fi
# Powerlevel10k prompt
zinit ice depth=1
zinit light romkatv/powerlevel10k
# Utilities to defer execution of slow scripts
zinit light romkatv/zsh-defer
# command highlighting
zinit wait'1' silent for \
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
zdharma-continuum/fast-syntax-highlighting \
atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions
# better vim keybindings
VIM_MODE_ESC_PREFIXED_WANTED=''
zinit wait lucid for \
atload"bindkey -rpM viins '^[^['" \
@softmoth/zsh-vim-mode
# fzf integration
# atclone is used to fix ffmpeg issues with p10k (#176)
zinit wait lucid light-mode for \
reset atclone'sed -ie "s/COLUMNS=500//" fzf-tab.zsh' \
atpull'%atclone' nocompile'!' \
@Aloxaf/fzf-tab \
multisrc:'shell/*.zsh' @junegunn/fzf
# get fzf ripgrep preview script
zinit wait lucid for \
as'program' mv'bin/preview.sh -> fzf_rg_preview' \
pick'fzf_rg_preview' \
junegunn/fzf.vim
# fzf git complement
zinit wait'1' lucid for \
@IngoHeimbach/zsh-easy-motion \
wfxr/forgit
zinit wait lucid for \
@le0me55i/zsh-extract
## Completions
zinit lucid for \
blockf \
zsh-users/zsh-completions
zinit wait lucid as"completion" for \
OMZP::docker-compose \
OMZP::docker/_docker \
OMZP::cargo \
@spwhitt/nix-zsh-completions
fi
# }}}
# Functions {{{
# Set keyboard to latam and remap escape
kb_lat() {
setxkbmap -option caps:swapescape -layout latam
}
# Set keyboard to esp
kb_esp() {
setxkbmap -option -layout es
}
# }}}
# Alias {{{
alias vi=nvim
alias xclip="xclip -selection c"
alias ls="ls --color=auto"
alias l="exa --icons"
alias ll="exa -l --icons"
alias la="exa -la --icons"
alias lt="exa --tree --level=2 --icons"
alias gitc="git commit -m"
alias gits="git status"
alias idris2="rlwrap idris2"
alias ddd="dragon-drop"
# Useful python executables
alias httpwatcher="pipx run httpwatcher"
alias pre-commit="pipx run pre-commit"
alias pycln="pipx run pycln"
# xdg-open in background
xo() {
xdg-open "$@" &>/dev/null & disown
}
# Fix white flash before startup
emacs() {
/usr/bin/env emacsclient -cnqua '' "$@"
}
alias nrepl='clj -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" --interactive'
alias objdump='objdump -M intel'
# }}}
# Keybindings {{{
# Missing bindings for underscore
bindkey -M vicmd '_' beginning-of-line
bindkey -M visual '_' beginning-of-line
bindkey -M viopp '_' beginning-of-line
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[3~" delete-char
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
# Remove annoying execute command after ^[:
bindkey -rM vicmd ':'
# }}}
# Cursor style {{{
function _set_cursor() {
echo -ne $1
}
function _set_block_cursor() { _set_cursor '\e[2 q' }
function _set_line_cursor() { _set_cursor '\e[6 q' }
function zle-keymap-select {
if [[ ${KEYMAP} = vicmd || $1 = 'block' ]]; then
_set_block_cursor
else
_set_line_cursor
fi
}
zle -N zle-keymap-select
precmd_functions+=(_set_line_cursor)
function zle-line-init() { zle -K viins; _set_line_cursor }
function zle-line-finish() { _set_block_cursor }
zle -N zle-line-finish
# }}}
# Path {{{
# ghcup must be before /usr/bin
PATH=${PATH/:\/usr\/bin:/:$HOME/.ghcup/bin:/usr/bin:}
export PATH
path+=( $HOME/.local/bin )
path+=( /usr/lib/emscripten )
path+=( $HOME/dotfiles/scripts )
path+=( $HOME/.elan/bin )
path+=( $HOME/.cargo/bin )
path+=( $HOME/.yarn/bin )
# }}}
# Bottom setup {{{
# Disable annoying Ctrl-S
if [[ -t 0 && $- = *i* ]]; then
stty -ixon
fi
# fnm
command -v fnm> /dev/null 2>&1 && \
zsh-defer -c 'eval `fnm env`'
# sdkman
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && \
zsh-defer -t1 source "$HOME/.sdkman/bin/sdkman-init.sh"
# nix
[ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ] && \
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
# direnv
direnv version &>/dev/null && eval "$(direnv hook zsh)"
# Load aws-cli completion
function load_aws_cli() {
if type aws_completer &> /dev/null; then
autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit
compinit
complete -C '/usr/local/bin/aws_completer' aws
fi
}
zsh-defer load_aws_cli
type keychain &> /dev/null \
&& eval "$(keychain --eval --quiet)"
# Powerlevel10k prompt configuration
# OS name prompt segment
function prompt_os_name() {
p10k segment -f white -t archlinux
}
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# }}}