initial checkin
[zsh-lovers.git] / zsh_people / caphuso / zshrc
1 # this is not useable as a life ~/.zshrc, but you might get one or two ideas
2 # from it. So don't blame anyone but yourself if something gets messed up.
3
4 autoload -U checkmail # needed for my prompt
5 autoload -U colors && colors # make ${f,b}g{,_{,no_}bold} availabl
6 autoload -U compinit && compinit # load new completion system
7 autoload -U edit-command-line # later bound to C-z e
8 autoload -U zed # what, your shell can't edit files?
9 autoload -U zmv # who needs mmv or rename?
10 bindkey -e # force emacs keybindings no matter what $VISUAL and $EDITOR say
11 zmodload zsh/complist
12 zmodload zsh/deltochar
13 zmodload zsh/mathfunc
14
15 # autoload my personal functions
16 autoload ${fpath[1]}/*(:t)
17
18 # some terminal specific magic
19 # look for the zkbd stuff in 'man zshcontrib'
20 # note: i renamed and moved the resulting files
21 case $TERM in
22     linux)
23         . ~/.zsh/zkbd/$TERM
24         ;;
25     screen)
26         . ~/.zsh/zkbd/$TERM
27         ;;
28     gnome*)
29         . ~/.zsh/zkbd/$TERM
30         ;;
31     vt420*)
32         . ~/.zsh/zkbd/$TERM
33         ;;
34     rxvt)
35         . ~/.zsh/zkbd/$TERM
36         ;;
37     xterm*)
38         . ~/.zsh/zkbd/$TERM
39         ;;
40 esac
41
42 [[ -z $DISPLAY ]] && setterm -bfreq 100 -blength 50 || resize > /dev/null 2>&1
43
44 # some external files
45 source ~/.zsh/zsh_alias
46 source ~/.zsh/zsh_foo
47 source ~/.zsh/zsh_prompt || PROMPT='%n@%m %40<...<%B%~%b%<< $ '
48
49 # some options to set
50 setopt NO_rm_star_wait
51 setopt NO_auto_cd
52 setopt correct
53 setopt NO_auto_menu
54 setopt NO_menucomplete
55 setopt autolist
56 setopt NO_complete_in_word
57 setopt complete_aliases
58 setopt NO_mark_dirs
59 setopt NO_multios
60 setopt notify
61 setopt path_dirs
62 setopt NO_singlelinezle
63 setopt NO_hup
64 setopt NO_beep
65 setopt NO_nullglob
66 setopt extended_glob
67 setopt numeric_glob_sort
68 setopt NO_check_jobs
69 setopt list_packed
70 setopt NO_list_rows_first
71 setopt bare_glob_qual
72 setopt NO_clobber
73 setopt histallowclobber
74 setopt append_history
75 setopt histignorealldups
76 setopt histignorespace
77 setopt extended_history
78 setopt histreduceblanks
79 setopt hist_no_store
80 setopt NO_hist_verify
81 setopt NO_auto_name_dirs
82 setopt hash_cmds
83 setopt hash_dirs
84 setopt pushd_ignore_dups
85 setopt NO_pushd_minus
86 setopt auto_pushd
87 setopt pushd_silent
88 setopt pushd_to_home
89 [[ $VERSION == 4.1* ]] && setopt auto_continue
90 setopt magic_equal_subst
91 setopt NO_print_exit_value     # don't print exit value if non-zero
92 setopt glob_complete   # echo *<TAB> -> menu completion
93 setopt rc_quotes       # print '''' -> '
94 setopt ksh_option_print
95 setopt rc_expand_param  # foo=(1 2);a${foo}b -> 'a1b a2b', not 'a1 b2'
96 setopt no_flow_control
97 setopt brace_ccl       # {a-c} -> 'a b c'
98 setopt bsd_echo
99 setopt always_last_prompt # necessary for menu selection
100
101 # some zle stuff
102 autoload _history_complete_word
103 autoload history-search-end
104 zle -N edit-command-line
105 zle -N local-run-help
106 zle -N run-as-root
107 zle -N run-with-noglob
108 zle -N run-as-command
109 zle -N run-as-builtin
110 zle -N run-without-completion
111 zle -N show-history
112 zle -N show-dirstack
113 zle -N silly-calc
114 zle -N zsh-query-replace
115 zle -N history-beginning-search-backward-end history-search-end
116 zle -N history-beginning-search-forward-end history-search-end
117 zle -C lamatch complete-word _generic
118 zle -C lappr complete-word _generic
119 zle -C lhist complete-word _generic
120 zle -C most-recent-file menu-complete _generic
121 autoload url-quote-magic
122 zle -N self-insert url-quote-magic
123
124 # default keymap
125 # bindkey -m
126 bindkey '^Ze' edit-command-line
127 bindkey '^Zg' run-with-noglob
128 bindkey '^Zc' run-as-command
129 bindkey '^Zb' run-as-builtin
130 bindkey '^Zn' run-without-completion
131 bindkey '^Zh' show-history
132 bindkey '^Zd' show-dirstack
133 bindkey '^Xd' delete-to-char
134 bindkey '^Xz' zap-to-char
135 bindkey '^Xi' lamatch
136 bindkey '^Xl' lappr
137 bindkey '^Xc' _correct_filename
138 bindkey '^Xh' _complete_help
139 bindkey '^X?' _complete_debug
140 bindkey '^Xr' most-recent-file
141 bindkey '^Q' push-line-or-edit
142 bindkey '^I' complete-word
143 if (( $+key )); then
144     bindkey -r ${key[Up]}
145     bindkey -r ${key[Down]}
146     bindkey -r ${key[Left]}
147     bindkey -r ${key[Right]}
148 fi
149
150 # emacs keymap
151 bindkey -M emacs '^W' kill-region
152 bindkey -M emacs '^[%' zsh-query-replace
153 bindkey -M emacs '^[S' run-as-root
154 bindkey -M emacs '^[H' local-run-help
155 bindkey -M emacs '^[^M' silly-calc
156 bindkey -M emacs '^[n' history-beginning-search-forward-end
157 bindkey -M emacs '^[p' history-beginning-search-backward-end
158 bindkey -M emacs '^[/' lhist
159 bindkey -M emacs '^[Q' delete-to-char
160 bindkey -M emacs '^[Z' zap-to-char
161
162 autoload -U select-word-style
163 select-word-style n
164
165 zle -N shell-forward-word forward-word-match
166 bindkey -M emacs '\eF' shell-forward-word
167 zstyle ':zle:shell-forward-word' word-style shell
168
169 zle -N shell-backward-word backward-word-match
170 bindkey -M emacs '\eB' shell-backward-word
171 zstyle ':zle:shell-backward-word' word-style shell
172
173 zle -N shell-kill-word kill-word-match
174 bindkey -M emacs '\eD' shell-kill-word
175 zstyle ':zle:shell-kill-word' word-style shell
176
177 zle -N shell-backward-kill-word backward-kill-word-match
178 bindkey -M emacs '\ek' shell-backward-kill-word
179 zstyle ':zle:shell-backward-kill-word' word-style shell
180
181 # vicmd keymap
182 bindkey -M vicmd 'u' undo
183 bindkey -M vicmd 'q' delete-to-char
184 bindkey -M vicmd '^Q' zap-to-char
185 bindkey -M vicmd '^[x' execute-named-cmd
186 bindkey -M vicmd '^R' redo
187 bindkey -M vicmd '^[a' accept-and-hold
188 bindkey -M vicmd 'Q' zsh-query-replace
189
190 # viins keymap
191 bindkey -M viins '^[x' execute-named-cmd
192 bindkey -M viins '^[.' insert-last-word
193 bindkey -M viins '^[a' accept-and-hold
194 bindkey -M viins '^P' up-line-or-history
195 bindkey -M viins '^N' down-line-or-history
196 bindkey -M viins '^I' complete-word
197 bindkey -r '^Z'
198 bindkey -r '^X'
199
200 # menu selection
201 bindkey '^Zm' menu-select
202 bindkey -M menuselect '^P'  up-line-or-history
203 bindkey -M menuselect '^N'  down-line-or-history
204 bindkey -M menuselect '^B' backward-char
205 bindkey -M menuselect '^F' forward-char
206 bindkey -M menuselect '^O' accept-and-infer-next-history
207 bindkey -M menuselect '^_' undo
208 bindkey -M menuselect '^A' accept-and-menu-complete
209
210 # some external commands
211 [[ -x =lesspipe ]] && eval $(lesspipe) # set $LESS{OPEN,CLOSE}
212 [[ -x =dircolors ]] && eval $(dircolors ~/.dircolors) # set $LS_COLORS
213
214 # forgot why i set this :-(
215 maildirectory=~/mail
216
217 # completion system configuration
218 zstyle ':completion:*' completer \
219     _complete _match _correct _complete:-extended _prefix \
220     _complete:-substring
221 zstyle ':completion:*:correct:*' max-errors 0 numeric
222 zstyle ':completion:*:correct:*' insert-unambiguous true
223 zstyle ':completion:*:correct:*' original false
224 zstyle ':completion:*:expand:*' group-order all-expansions expansions
225 zstyle ':completion:lappr:*' completer _approximate
226 zstyle ':completion:lappr:*:approximate:*' max-errors 3 numeric
227 zstyle ':completion:lamatch:*' completer _all_matches
228 zstyle ':completion:lamatch:*' old-matches only
229 zstyle ':completion:lhist:*' completer _history
230 zstyle ':completion:lhist:*' range 1000:10
231 zstyle ':completion:*:match:*' match-original non-empty-value
232 zstyle ':completion:*' ambiguous true
233 zstyle ':completion:*' glob true
234 zstyle ':completion:*' word true
235 zstyle ':completion:*:-tilde-:*' group-order \
236     'named-directories' 'path-directories' 'users' 'expand'
237 zstyle ':completion:*:ssh:*' group-order 'users' 'hosts'
238 zstyle ':completion:all-matches:*' old-matches only
239 zstyle ':completion:all-matches:*' completer _all_matches
240 zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*~' '\#*\#' '*.zwc'
241 zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
242 zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
243 zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))'
244 zstyle ':completion:*:-subscript-:*' tag-order indexes parameters
245 zstyle ':completion:*:cd:*' tag-order \
246     local-directories directory-stack named-directories path-directories
247 zstyle ':completion:*:complete-extended:*' matcher-list \
248     'm:{a-z}={A-Z}' 'r:|[+._-]=*'
249 zstyle ':completion:*:complete-substring:*' matcher-list \
250     'l:|=**'
251 zstyle ':completion:*:mutt:*' users \
252     ${${${(f)"$(<~/.mutt_mail_aliases)"}#alias[[:space:]]}%%[[:space:]]*}
253 zstyle ':completion:*:urls' urls ~/.zsh/urls
254 zstyle ':completion:*:ping:*' hosts host.foo.invalid 
255     host{{1..5},}.at.some.net.invalid
256 zstyle ':completion::*' list-colors ${(s.:.)LS_COLORS}
257 zstyle ':completion:*' users-hosts username@localhost \
258     user1@host.invalid \
259     user2@otherhost.invalid
260 zstyle ':completion:*' group-name ''
261 zstyle ':completion:*' ignore-parents pwd parent ..
262 zstyle ':completion:*' remove-all-dups true
263 zstyle ':completion:*' select-scroll -1
264 zstyle ':completion:*' special-dirs '..'
265 zstyle ':completion:*' use-cache yes
266 zstyle ':completion:*' menu select
267 zstyle ':completion:*:descriptions' format \
268     $'%{\e[0;31m%}completing %d%{\e[0m%}'
269 zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%}'
270 zstyle ':completion:*' insert-unambiguous true
271 zstyle ':completion:*' range 200:20
272 zstyle ':completion:*' select-prompt '%SSelect:  lines: %L  matches: %M  [%p]'
273 zstyle ':completion:*' sort true
274
275 zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
276 zstyle ':completion:*:*:rm:*' file-patterns '(*~|\\#*\\#):backup-files' \
277     '*.zwc:zsh\ bytecompiled\ files' '(|[a-z]#-[0-9]#-[0-9]#-[0-9]#.)core(|.*):core\ files' '*:all-files'
278 zstyle ':completion:*:rm:*' ignore-line true
279 zstyle ':completion:*:kill:*' insert-ids single
280 zstyle ':completion:*:*:kill:*' menu yes select
281 zstyle ':completion:*:kill:*' force-list always
282 zstyle ':completion:*' keep-prefix changed
283 zstyle ':completion:*:man:*' separate-sections true
284 zstyle ':completion:*:mplayer:*:bookmark' mplayer-bookmark ~/.zsh/mplayer-bookmark
285 zstyle ':completion:most-recent-file:*' match-original both
286 zstyle ':completion:most-recent-file:*' completer _menu _files _match
287 zstyle ':completion:most-recent-file:*' file-sort modification
288 zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files'
289 zstyle ':completion:most-recent-file:*' hidden all
290
291 zstyle ':completion:*:xpdf:*' menu true
292 zstyle ':completion:*:xpdf:*' file-patterns '*.pdf(.-)' '*(/-)'
293 zstyle ':completion:*:xpdf:*' file-sort time
294 zstyle ':completion:*:xdvi:*' menu true
295 zstyle ':completion:*:xdvi:*' file-patterns '*.dvi(|.gz|.Z)(.-)' '*(/-)'
296 zstyle ':completion:*:xdvi:*' file-sort time
297
298 compdef _gnu_generic cp mv gpg df stow uname ipacsum fetchipac
299 compdef _man pman