-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzshrc
270 lines (209 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
# vim: foldmethod=marker
# reload
alias reload='. ~/.zshenv && . ~/.zshrc && print "reloaded"'
# VARS {{{
autoload -U add-zsh-hook add-zle-hook-widget
# shell {{{
READNULLCMD=$PAGER
# bookmarks {{{
dot=~/Dotfiles
ll=~/Dotfiles/links
v=~/.vim
c=~/code
w=~/.wiki
p=~/.personal/
: ~{dot,ll,v,c,w,p}
# }}}
# prompts {{{
PROMPT_EOL_MARK='%S%F{red}$%f%s'
: ${PROMPT_DIRTRIM=2}
: ${prompt_date=}
: ${prompt_user=true}
: ${prompt_host=true}
: ${prompt_jobs=true}
: ${prompt_tty=}
: ${prompt_shell_name=}
: ${prompt_time=}
: ${prompt_dir=true}
: ${prompt_history=}
: ${prompt_venv=true}
GIT_PS1_SHOWDIRTYSTATE='true'
GIT_PS1_SHOWSTASHSTATE='true'
GIT_PS1_SHOWUNTRACKEDFILES='true'
GIT_PS1_SHOWUPSTREAM='auto'
GIT_PS1_STATESEPARATOR=' '
GIT_PS1_DESCRIBE_STYLE='branch'
GIT_PS1_SHOWCOLORHINTS=''
GIT_PS1_SHOWCONFLICTSTATE=yes
() {
local git gitprompt
git==git
gitprompt=${git:h:h}/etc/bash_completion.d/git-prompt.sh
[[ -r "$gitprompt" ]] && source "$gitprompt"
}
PS1=''
PS1+='${prompt_jobs:+"%(1j.%F{yellow}%j& %f.)"}'
PS1+='${prompt_history:+"%F{magenta}#%! %f"}'
PS1+='${prompt_user:+"%n ${prompt_host:+"@ %m "}"}'
PS1+='${prompt_dir:+"%F{cyan}∈ %($((PROMPT_DIRTRIM+2))~:%-1~/…/%${PROMPT_DIRTRIM}~:%$((PROMPT_DIRTRIM+1))~)%f "}'
PS1+='%F{yellow}$(__git_ps1 "%s ")%f'
PS1+=$'\n'
PS1+='%(?.%F{green}λ%f.%F{red}X %? λ%f)'
PS1+='%(!.%F{red}!%f.)'
PS1+=' '
RPS1=''
RPS1+='${prompt_venv:+${VIRTUAL_ENV:+"($(show_venv_name)) "}}'
RPS1+='${prompt_time:+"%F{blue}%T⧖ %f"}'
RPS1+='${prompt_date:+"%F{blue}%D{%e %B %Y} %f"}'
RPS1+='${prompt_tty:+"%F{green}%l %f"}'
RPS1+='${prompt_shell_name:+"%F{green}$ZSH_PATCHLEVEL %f"}'
PS2='» '
RPS2='%^'
PS4='+(%e)%N:%i> '
show_venv_name() {
local project_file="$VIRTUAL_ENV"/.project
if [[ -e "$project_file" ]]; then
<"$project_file" xargs basename
else
print "${VIRTUAL_ENV:h:t}"
fi
}
# prompts }}}
# options {{{
# why this is off by default is beyond me
setopt interactivecomments
# substitutions in prompts
setopt promptsubst
# and clear the right prompt when done
setopt transientrprompt
# history {{{
HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=$HISTSIZE
# don't save command if it starts with a space
HISTORY_IGNORE=' *'
# append, don't overwrite
setopt appendhistory
# append as you go
setopt incappendhistory
# share across sessions
# setopt sharehistory
# ignore duplicates
setopt histignoredups
# don't show duplicates more than once
setopt histfindnodups
# prefer to get rid of duplicates when history fills up
setopt histexpiredupsfirst
# verification of history expansions
setopt histverify
# history }}}
setopt noclobber
# but save them in history as clobbered, for quick corrections
setopt histallowclobber
setopt autocd
setopt globstarshort
setopt correct
# make some more sense:
# no multi io redirections
setopt nomultios
# exports are not implicitly global
setopt noglobalexport
# completion {{{
setopt autolist
setopt automenu
setopt completeinword
zstyle ':completion:*' menu select=5
zstyle ':completion:*' list-separator '#'
# zstyle ':completion:*:descriptions' format 'Completing %d'
# zstyle ':completion:*' group-name ''
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# regular ->
# smartcase ->
# partial around any in [] ->
# left completion
# this is installed as common-commands by the completion engine,
# and I DONT LIKE IT
# visually, sure, the whole
# command -- description
# thing is nice, but most of the commands I *know* already (I'm not learning
# git), and further it makes it stupid hard to get to aliases in completion
zstyle ':completion:*:*:git:*' tag-order all-commands
# completion }}}
# options }}}
# keys {{{
# widgets {{{
zle_highlight=(
'isearch:fg=green,standout'
region:standout
'special:fg=red'
'suffix:fg=magenta'
paste:standout
)
run-fg () {
zle push-input
BUFFER="fg"
zle accept-line
}
zle -N run-fg
zle -N edit-command-line
zle -N delete-surround surround
zle -N add-surround surround
zle -N change-surround surround
zle -N insert-files
[[ "$(type -w run-help)" == 'run-help: alias' ]] && unalias run-help
zle -N insert-composed-char
zle -N predict-on
zle -N predict-off
# widgets }}}
# use vi bindings
bindkey -v
# but fix backspace
bindkey -M viins '^H' backward-delete-char
bindkey -M viins '^?' backward-delete-char
bindkey -M viins '^U' backward-kill-line
bindkey -M viins '^W' backward-kill-word
bindkey -M viins '^Y' yank
# and set incremental searches
bindkey -M viins '^R' history-incremental-search-backward
# let 'space' magically expand history command-line fu
bindkey -M viins ' ' magic-space
bindkey -M viins '^Xq' quote-line
# add my favorite editing trick
bindkey -M vicmd '^V' edit-command-line
# and another I picked up
bindkey -M viins '^Z' run-fg
# and this!!
bindkey -a cs change-surround
bindkey -a ds delete-surround
bindkey -a ys add-surround
bindkey -M visual S add-surround
# better and better
bindkey -M viins '^Xf' insert-files
bindkey -M viins '^X^F' insert-files
bindkey -M viins '^N' menu-complete
bindkey -M viins '^P' reverse-menu-complete
# shift-tab
bindkey -M viins '\e[Z' reverse-menu-complete
bindkey -M vicmd 'K' run-help
bindkey -M viins '^K' insert-composed-char
bindkey -M viins '^S' push-line
# keys }}}
# term {{{
# disable flow control
stty -ixon -ixoff
# term }}}
# shell }}}
# VARS }}}
# custom {{{
export GIT_COMPLETION_SHOW_ALL=1
export GIT_COMPLETION_SHOW_ALL_COMMANDS=1
compinit
# I use <esc>/ to start a search, but I type fast enough for it to trigger
# _history-complete-older. Get rid of it
# It has to be down here, though, because it seems compinit triggers it, at
# least when
# /usr/local/Cellar/zsh/5.8_1/share/zsh/functions/_history_complete_word is on
# the fpath, because its first line is
# #compdef -K _history-complete-older complete-word \e/ _history-complete-newer complete-word \e,
bindkey -r '\e/'
# custom }}}