initial checkin
[zsh-lovers.git] / zsh_people / adam_spiers / zshrc
1 #!/bin/zsh
2 #
3 # .zshrc
4 # for zsh 3.1.6 and newer (may work OK with earlier versions)
5 #
6 # by Adam Spiers <adam@spiers.net>
7 #
8 # Best viewed in emacs folding mode (folding.el).
9 # (That's what all the # {{{ and # }}} are for.)
10 #
11 # $Id: .zshrc,v 1.255 2004/03/15 21:24:26 adams Exp $
12 #
13
14 # {{{ To do list
15
16 #
17 #    - du1
18 #    - Do safes?kill(all)? functions
19 #
20
21 # }}}
22
23 # {{{ What version are we running?
24
25 if ! (( $+ZSH_VERSION_TYPE )); then
26   if [[ $ZSH_VERSION == 3.0.<->* ]]; then ZSH_STABLE_VERSION=yes; fi
27   if [[ $ZSH_VERSION == 3.1.<->* ]]; then ZSH_DEVEL_VERSION=yes;  fi
28
29   ZSH_VERSION_TYPE=old
30   if [[ $ZSH_VERSION == 3.1.<6->* ||
31         $ZSH_VERSION == 3.<2->.<->*  ||
32         $ZSH_VERSION == 4.<->* ]]
33   then
34     ZSH_VERSION_TYPE=new
35   fi
36 fi
37
38 # }}}
39 # {{{ Profiling
40
41 [[ -n "$ZSH_PROFILE_RC" ]] && which zmodload >&/dev/null && zmodload zsh/zprof
42
43 # }}}
44 # {{{ Loading status
45
46 zshrc_load_status () {
47   # \e[0K is clear to right
48   echo -n "\r.zshrc load: $* ... \e[0K"
49 }
50
51 # }}}
52
53 # {{{ Options
54
55 zshrc_load_status 'setting options'
56
57 setopt                       \
58      NO_all_export           \
59         always_last_prompt   \
60      NO_always_to_end        \
61         append_history       \
62         auto_cd              \
63         auto_list            \
64         auto_menu            \
65      NO_auto_name_dirs       \
66         auto_param_keys      \
67         auto_param_slash     \
68         auto_pushd           \
69         auto_remove_slash    \
70      NO_auto_resume          \
71         bad_pattern          \
72         bang_hist            \
73      NO_beep                 \
74      NO_brace_ccl            \
75         correct_all          \
76      NO_bsd_echo             \
77         cdable_vars          \
78      NO_chase_links          \
79      NO_clobber              \
80         complete_aliases     \
81         complete_in_word     \
82      NO_correct              \
83         correct_all          \
84         csh_junkie_history   \
85      NO_csh_junkie_loops     \
86      NO_csh_junkie_quotes    \
87      NO_csh_null_glob        \
88         equals               \
89         extended_glob        \
90         extended_history     \
91         function_argzero     \
92         glob                 \
93      NO_glob_assign          \
94         glob_complete        \
95      NO_glob_dots            \
96         glob_subst           \
97         hash_cmds            \
98         hash_dirs            \
99         hash_list_all        \
100         hist_allow_clobber   \
101         hist_beep            \
102         hist_ignore_dups     \
103         hist_ignore_space    \
104      NO_hist_no_store        \
105         hist_verify          \
106      NO_hup                  \
107      NO_ignore_braces        \
108      NO_ignore_eof           \
109         interactive_comments \
110      NO_list_ambiguous       \
111      NO_list_beep            \
112         list_types           \
113         long_list_jobs       \
114         magic_equal_subst    \
115      NO_mail_warning         \
116      NO_mark_dirs            \
117      NO_menu_complete        \
118         multios              \
119         nomatch              \
120         notify               \
121      NO_null_glob            \
122         numeric_glob_sort    \
123      NO_overstrike           \
124         path_dirs            \
125         posix_builtins       \
126      NO_print_exit_value     \
127      NO_prompt_cr            \
128         prompt_subst         \
129         pushd_ignore_dups    \
130      NO_pushd_minus          \
131         pushd_silent         \
132         pushd_to_home        \
133         rc_expand_param      \
134      NO_rc_quotes            \
135      NO_rm_star_silent       \
136      NO_sh_file_expansion    \
137         sh_option_letters    \
138         short_loops          \
139      NO_sh_word_split        \
140      NO_single_line_zle      \
141      NO_sun_keyboard_hack    \
142         unset                \
143      NO_verbose              \
144         zle
145
146 if [[ $ZSH_VERSION_TYPE == 'new' ]]; then
147   setopt                       \
148         hist_expire_dups_first \
149         hist_ignore_all_dups   \
150      NO_hist_no_functions      \
151      NO_hist_save_no_dups      \
152         inc_append_history     \
153         list_packed            \
154      NO_rm_star_wait
155 fi
156
157 if [[ $ZSH_VERSION == 3.0.<6->* || $ZSH_VERSION_TYPE == 'new' ]]; then
158   setopt \
159         hist_reduce_blanks
160 fi
161
162 # }}}
163 # {{{ Environment
164
165 zshrc_load_status 'setting environment'
166
167 # {{{ INFOPATH
168
169 [[ "$ZSH_VERSION_TYPE" == 'old' ]] || typeset -T INFOPATH infopath
170 typeset -U infopath # no duplicates
171 export INFOPATH
172 infopath=( 
173           ~/local/$OSTYPE/info(N)
174           ~/local/info(N)
175           /usr/local/info(N)
176           /usr/info(N)
177           $infopath
178          )
179
180 # }}}
181 # {{{ MANPATH
182
183 case "$OSTYPE" in
184   linux*)
185     # Don't need to do anything through the cunningness
186     # of AUTOPATH in /etc/man.config!
187     ;;
188
189   *)
190     # Don't trust system-wide MANPATH?  Remember what it was, for reference.
191     sysmanpath=$HOME/.sysmanpath
192     [ -e $sysmanpath ] || echo "$MANPATH" > $sysmanpath
193     manpath=( )
194     for dir in "$path[@]"; do
195       [[ "$dir" == */bin ]] || continue
196       mandir="${dir//\/bin//man}"
197       [[ -d "$mandir" ]] && manpath=( "$mandir" "$manpath[@]" )
198     done
199
200     # ... or *do* trust system-wide MANPATH
201     #MANPATH=/usr/local/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/sbin:/sbin:$MANPATH
202     ;;
203 esac
204
205 # }}}
206
207 # Variables used by zsh
208
209 # {{{ Choose word delimiter characters in line editor
210
211 WORDCHARS=''
212
213 # }}}
214 # {{{ Save a large history
215
216 HISTFILE=~/.zshhistory
217 HISTSIZE=3000
218 SAVEHIST=3000
219
220 # }}}
221 # {{{ Maximum size of completion listing
222
223 #LISTMAX=0    # Only ask if line would scroll off screen
224 LISTMAX=1000  # "Never" ask
225
226 # }}}
227 # {{{ Watching for other users
228
229 LOGCHECK=60
230 WATCHFMT="[%B%t%b] %B%n%b has %a %B%l%b from %B%M%b"
231
232 # }}}
233 # {{{ Auto logout
234
235 TMOUT=1800
236 #TRAPALRM () {
237 #  clear
238 #  echo Inactivity timeout on $TTY
239 #  echo
240 #  vlock -c
241 #  echo
242 #  echo Terminal unlocked. [ Press Enter ]
243 #}
244
245 # }}}
246
247 # }}}
248 # {{{ Prompts
249
250 # Load the theme-able prompt system and use it to set a prompt.
251 # Probably only suitable for a dark background terminal.
252
253 local _find_promptinit
254 _find_promptinit=( $^fpath/promptinit(N) )
255 if (( $#_find_promptinit >= 1 )) && [[ -r $_find_promptinit[1] ]]; then
256   zshrc_load_status 'prompt system'
257
258   autoload -U promptinit
259   promptinit
260
261   PS4="trace %N:%i> "
262   #RPS1="$bold_colour$bg_red              $reset_colour"
263
264   # Default prompt style
265   adam2_colors=( white cyan cyan green )
266
267   if [[ -r $zdotdir/.zsh_prompt ]]; then
268     . $zdotdir/.zsh_prompt
269   fi
270
271   if [[ -r /proc/$PPID/cmdline ]] &&
272        egrep -q 'watchlogs|kates|nexus|vga' /proc/$PPID/cmdline;
273   then
274     # probably OK for fancy graphic prompt
275     if [[ "`prompt -h adam2`" == *8bit* ]]; then
276       prompt adam2 8bit $adam2_colors
277     else
278       prompt adam2 $adam2_colors
279     fi
280   else
281     if [[ "`prompt -h adam2`" == *plain* ]]; then
282       prompt adam2 plain $adam2_colors
283     else
284       prompt adam2 $adam2_colors
285     fi
286   fi
287
288   if [[ $TERM == tgtelnet ]]; then
289     prompt off
290   fi
291 else
292   PS1='%n@%m %B%3~%b %# '
293 fi
294
295 # }}}
296
297 # {{{ Completions
298
299 zshrc_load_status 'completion system'
300
301 # {{{ Set up new advanced completion system
302
303 if [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
304   autoload -U compinit
305   compinit -C # don't perform security check
306 else
307   print "\nAdvanced completion system not found; ignoring zstyle settings."
308   function zstyle { }
309   function compdef { }
310
311   # an antiquated, barebones completion system is better than nowt
312   which zmodload >&/dev/null && zmodload zsh/compctl
313 fi
314
315 # }}}
316 # {{{ General completion technique
317
318 # zstyle ':completion:*' completer \
319 #   _complete _prefix _approximate:-one _ignored \
320 #   _complete:-extended _approximate:-four
321 zstyle ':completion:*' completer _complete _prefix _ignored _complete:-extended
322
323 zstyle ':completion::prefix-1:*' completer _complete
324 zstyle ':completion:incremental:*' completer _complete _correct
325 zstyle ':completion:predict:*' completer _complete
326
327 zstyle ':completion:*:approximate-one:*'  max-errors 1
328 zstyle ':completion:*:approximate-four:*' max-errors 4
329
330 zstyle ':completion:*:complete-extended:*' \
331   matcher 'r:|[.,_-]=* r:|=*'
332
333 # }}}
334 # {{{ Fancy menu selection when there's ambiguity
335
336 #zstyle ':completion:*' menu yes select interactive
337 #zstyle ':completion:*' menu yes=long select=long interactive
338 #zstyle ':completion:*' menu yes=10 select=10 interactive
339
340 # }}}
341 # {{{ Completion caching
342
343 zstyle ':completion::complete:*' use-cache 1
344 zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
345
346 # }}}
347 # {{{ Expand partial paths
348
349 zstyle ':completion:*' expand 'yes'
350 zstyle ':completion:*' squeeze-slashes 'yes'
351
352 # }}}
353 # {{{ Include non-hidden dirs in globbed file completions for certain commands
354
355 #zstyle ':completion::complete:*' \
356 #  tag-order 'globbed-files directories' all-files 
357 #zstyle ':completion::complete:*:tar:directories' file-patterns '*~.*(-/)'
358
359 # }}}
360 # {{{ Don't complete backup files as executables
361
362 zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'
363
364 # }}}
365 # {{{ Don't complete uninteresting users
366
367 zstyle ':completion:*:*:*:users' ignored-patterns \
368         adm apache bin daemon games gdm halt ident junkbust lp mail mailnull \
369         named news nfsnobody nobody nscd ntp operator pcap postgres radvd \
370         rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
371
372 # ... unless we really want to.
373 zstyle '*' single-ignored show
374
375 # }}}
376 # {{{ Output formatting
377
378 # Separate matches into groups
379 zstyle ':completion:*:matches' group 'yes'
380
381 # Describe each match group.
382 zstyle ':completion:*:descriptions' format "%B---- %d%b"
383
384 # Messages/warnings format
385 zstyle ':completion:*:messages' format '%B%U---- %d%u%b' 
386 zstyle ':completion:*:warnings' format '%B%U---- no match for: %d%u%b'
387  
388 # Describe options in full
389 zstyle ':completion:*:options' description 'yes'
390 zstyle ':completion:*:options' auto-description '%d'
391
392 # }}}
393 # {{{ Array/association subscripts
394
395 # When completing inside array or association subscripts, the array
396 # elements are more useful than parameters so complete them first:
397 zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters 
398
399 # }}}
400 # {{{ Completion for 'kill'
401
402 zstyle ':completion:*:*:kill:*' menu yes select
403 zstyle ':completion:*:kill:*' force-list always
404
405 # }}}
406 # {{{ Simulate my old dabbrev-expand 3.0.5 patch 
407
408 zstyle ':completion:*:history-words' stop yes
409 zstyle ':completion:*:history-words' remove-all-dups yes
410 zstyle ':completion:*:history-words' list false
411 zstyle ':completion:*:history-words' menu yes
412
413 # }}}
414 # {{{ Common usernames
415
416 # users=( tom dick harry )
417
418 #zstyle ':completion:*' users $users
419
420 # }}}
421 # {{{ Common hostnames
422
423 if [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
424   : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
425 # _ssh_known_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
426 else
427   # Older versions don't like the above cruft
428   _etc_hosts=()
429 fi
430
431 hosts=(
432     "$_etc_hosts[@]"
433
434     localhost
435
436     # ftp sites
437     sunsite.org.uk
438 )
439
440 zstyle ':completion:*' hosts $hosts
441
442 # }}}
443 # {{{ (user,host) pairs
444
445 # All my accounts:
446 #my_accounts=(
447 #  {joe,root}@mymachine.com
448 #  jbloggs@myothermachine.com
449 #)
450
451 zstyle ':completion:*:my-accounts' users-hosts $my_accounts
452
453 # Other people's accounts:
454 #other_accounts=(
455 #  {fred,root}@hismachine.com
456 #  vera@hermachine.com
457 #)
458 #zstyle ':completion:*:other-accounts' users-hosts $other_accounts
459
460 # }}}
461 # {{{ (host, port, user) triples for telnet
462
463 #  telnet_users_hosts_ports=(
464 #    user1@host1:
465 #    user2@host2:
466 #    @mail-server:{smtp,pop3}
467 #    @news-server:nntp
468 #    @proxy-server:8000
469 #  )
470 #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports
471
472 # }}}
473
474 # }}}
475 # {{{ Aliases and functions
476
477 zshrc_load_status 'aliases and functions'
478
479 # {{{ Motion/editing
480
481 # {{{ Better word navigation
482
483 # Remember, WORDCHARS is defined as a 'list of non-alphanumeric
484 # characters considered part of a word by the line editor'.
485
486 # Elsewhere we set it to the empty string.
487
488 _my_extended_wordchars='*?_-.[]~=&;!#$%^(){}<>:@,\\'
489 _my_extended_wordchars_space="${_my_extended_wordchars} "
490 _my_extended_wordchars_slash="${_my_extended_wordchars}/"
491
492 # is the current position \-quoted ?
493 is_backslash_quoted () {
494     test "${BUFFER[$CURSOR-1,CURSOR-1]}" = "\\"
495 }
496
497 unquote-forward-word () {
498     while is_backslash_quoted
499       do zle .forward-word
500     done
501 }
502
503 unquote-backward-word () {
504     while is_backslash_quoted
505       do zle .backward-word
506     done
507 }
508
509 backward-to-space () {
510     local WORDCHARS="${_my_extended_wordchars_slash}"
511     zle .backward-word
512     unquote-backward-word
513 }
514
515 forward-to-space () {
516      local WORDCHARS="${_my_extended_wordchars_slash}"
517      zle .forward-word
518      unquote-forward-word
519 }
520
521 backward-to-/ () {
522     local WORDCHARS="${_my_extended_wordchars}"
523     zle .backward-word
524     unquote-backward-word
525 }
526
527 forward-to-/ () {
528      local WORDCHARS="${_my_extended_wordchars}"
529      zle .forward-word
530      unquote-forward-word
531 }
532
533 # Create new user-defined widgets pointing to eponymous functions.
534 zle -N backward-to-space
535 zle -N forward-to-space
536 zle -N backward-to-/
537 zle -N forward-to-/
538
539 # }}}
540 # {{{ kill-region-or-backward-(big-)word
541
542 # autoloaded
543 zle -N kill-region-or-backward-word
544 zle -N kill-region-or-backward-big-word
545
546 # }}}
547 # {{{ kill-big-word
548
549 kill-big-word () {
550     local WORDCHARS="${_my_extended_wordchars_slash}"
551     zle .kill-word
552 }
553
554 zle -N kill-big-word
555
556 # }}}
557
558 zle -N incremental-complete-word
559
560 # }}}
561 # {{{ zrecompile
562
563 autoload zrecompile
564
565 # }}}
566 # {{{ which/where
567
568 # reverse unwanted aliasing of `which' by distribution startup
569 # files (e.g. /etc/profile.d/which*.sh); zsh's which is perfectly
570 # good as is.
571
572 alias which >&/dev/null && unalias which
573
574 alias wh=where
575
576 # }}}
577 # {{{ run-help
578
579 alias run-help >&/dev/null && unalias run-help
580 autoload run-help
581
582 # }}}
583 # {{{ zcalc
584
585 autoload zcalc
586
587 # }}}
588 # {{{ Restarting zsh or bash; reloading .zshrc or functions
589
590 bash () {
591   NO_SWITCH="yes" command bash "$@"
592 }
593
594 restart () {
595   exec $SHELL $SHELL_ARGS "$@"
596 }
597
598 profile () {
599   ZSH_PROFILE_RC=1 $SHELL "$@"
600 }
601
602 reload () {
603   if [[ "$#*" -eq 0 ]]; then
604     . $zdotdir/.zshrc
605   else
606     local fn
607     for fn in "$@"; do
608       unfunction $fn
609       autoload -U $fn
610     done
611   fi
612 }
613 compdef _functions reload
614
615 # }}}
616 # {{{ ls aliases
617
618 if ls -F --color >&/dev/null; then
619   alias ls='command ls -F --color'
620 elif ls -F >&/dev/null; then
621   alias ls='command ls -F'
622 elif ls --color >&/dev/null; then
623   alias ls='command ls --color'
624 fi
625
626 # jeez I'm lazy ...
627 alias l='ls -lh'
628 alias ll='ls -l'
629 alias la='ls -lha'
630 alias lsa='ls -ah'
631 alias lsd='ls -d'
632 alias lsh='ls -dh .*'
633 alias lsr='ls -Rh'
634 alias ld='ls -ldh'
635 alias lt='ls -lth'
636 alias lrt='ls -lrth'
637 alias lart='ls -larth'
638 alias lr='ls -lRh'
639 alias lsL='ls -L'
640 alias lL='ls -Ll'
641 alias sl=ls # often screw this up
642
643 # }}}
644 # {{{ File management/navigation
645
646 # {{{ Changing/making/removing directory
647
648 alias -g ...=../..
649 alias -g ....=../../..
650 alias -g .....=../../../..
651 alias -g ......=../../../../..
652 alias cd..='cd ..'
653 alias cd...='cd ../..'
654 alias cd....='cd ../../..'
655 alias cd.....='cd ../../../..'
656 # blegh
657 alias ..='cd ..'
658 alias ../..='cd ../..'
659 alias ../../..='cd ../../..'
660 alias ../../../..='cd ../../../..'
661 alias ../../../../..='cd ../../../../..'
662
663 alias cd/='cd /'
664
665 alias 1='cd -'
666 alias 2='cd +2'
667 alias 3='cd +3'
668 alias 4='cd +4'
669 alias 5='cd +5'
670 alias 6='cd +6'
671 alias 7='cd +7'
672 alias 8='cd +8'
673 alias 9='cd +9'
674
675 # Sweet trick from zshwiki.org :-)
676 cd () {
677   if (( $# != 1 )); then
678     builtin cd "$@"
679     return
680   fi
681
682   if [[ -f "$1" ]]; then
683     builtin cd "$1:h"
684   else
685     builtin cd "$1"
686   fi
687 }
688
689 z () {
690   cd ~/"$1"
691 }
692
693 alias md='mkdir -p'
694 alias rd=rmdir
695
696 alias d='dirs -v'
697
698 po () {
699   popd "$@"
700   dirs -v
701 }
702
703 # }}}
704 # {{{ Renaming
705
706 autoload zmv
707 alias mmv='noglob zmv -W'
708
709 # }}}
710
711 # }}}
712 # {{{ Job/process control
713
714 alias j='jobs -l'
715 alias dn=disown
716
717 # }}}
718 # {{{ History
719
720 alias h='history -$LINES'
721
722 # }}}
723 # {{{ Environment
724
725 alias ts=typeset
726 compdef _typeset ts
727
728 # }}}
729 # {{{ Terminal
730
731 alias cls='clear'
732 alias term='echo $TERM'
733 # {{{ Changing terminal window/icon titles
734
735 which cx >&/dev/null || cx () { }
736
737 if [[ "$TERM" == ([Ex]term*|screen*) ]]; then
738   # Could also look at /proc/$PPID/cmdline ...
739   cx
740 fi
741
742 # }}}
743 alias sc=screen
744
745 # }}}
746 # {{{ Other users
747
748 compdef _users lh
749
750 alias f=finger
751 compdef _finger f
752
753 # su changes window title, even if we're not a login shell
754 su () {
755   command su "$@"
756   cx
757 }
758
759 # }}}
760 # {{{ No spelling correction
761
762 alias man='nocorrect man'
763 alias mysql='nocorrect mysql'
764 alias mysqlshow='nocorrect mysqlshow'
765 alias mkdir='nocorrect mkdir'
766 alias mv='nocorrect mv'
767 alias rj='nocorrect rj'
768
769 # }}}
770 # {{{ X windows related
771
772 # {{{ export DISPLAY=:0.0
773
774 alias sd='export DISPLAY=:0.0'
775
776 # }}}
777
778 # }}}
779 # {{{ Different CVS setups
780
781 # Sensible defaults
782 unset CVS_SERVER
783 export CVSROOT
784 export CVS_RSH=ssh
785
786 # see scvs function
787
788 # }}}
789 # {{{ Other programs
790
791 # {{{ less
792
793 alias v=less
794 alias vs='less -S'
795
796 # }}}
797 # {{{ mutt
798
799 m () {
800   cx mutt
801   mutt "$@"
802   cxx
803 }
804
805 compdef _mutt m
806
807 # }}}
808 # {{{ editors
809
810 # emacs, windowed
811 e () {
812   if [[ -n "$OTHER_USER" ]]; then
813     emacs -l $ZDOTDIR/.emacs "$@" &!
814   else
815     emacs "$@" &!
816   fi
817 }
818
819 # enable ^Z
820 alias pico='/usr/bin/pico -z'
821
822 if which vim >&/dev/null; then
823   alias vi=vim
824 fi
825
826 # }}}
827 # {{{ remote logins
828
829 ssh () {
830   cx -l "${(M)argv:#*@*}" # pick out user@host word from argv
831   command ssh "$@"
832   cxx
833 }
834
835 # Best to run this from .zshrc.local
836 #dsa >&DN || echo "ssh-agent setup failed; run dsa."
837
838 # }}}
839 # {{{ ftp
840
841 if which lftp >&/dev/null; then
842   alias ftp=lftp
843 elif which ncftp >&/dev/null; then
844   alias ftp=ncftp
845 fi
846
847 # }}}
848 # {{{ watching log files
849
850 alias tf='less +F'
851 alias tfs='less -S +F'
852
853 # }}}
854 # {{{ arch
855
856 if which larch >&/dev/null; then
857   alias a=larch
858   compdef _larch a
859 fi
860
861 # }}}
862 # {{{ bzip2
863
864 alias bz=bzip2
865 alias buz=bunzip2
866
867 # }}}
868
869 # }}}
870
871 # {{{ Global aliases
872
873 # WARNING: global aliases are evil.  Use with caution.
874
875 # {{{ For screwed up keyboards missing pipe
876
877 alias -g PIPE='|'
878
879 # }}}
880 # {{{ Paging with less / head / tail
881
882 alias -g L='| less'
883 alias -g LS='| less -S'
884 alias -g EL='|& less'
885 alias -g ELS='|& less -S'
886
887 alias -g H='| head'
888 alias -g HL='| head -20'
889 alias -g EH='|& head'
890 alias -g EHL='|& head -20'
891
892 alias -g T='| tail'
893 alias -g TL='| tail -20'
894 alias -g ET='|& tail'
895 alias -g ETL='|& tail -20'
896
897 # }}}
898 # {{{ Sorting / counting
899
900 alias -g C='| wc -l'
901
902 alias -g S='| sort'
903 alias -g US='| sort -u'
904 alias -g NS='| sort -n'
905 alias -g RNS='| sort -nr'
906
907 # }}}
908 # {{{ Common filenames
909
910 alias -g DN=/dev/null
911 alias -g VM=/var/log/messages
912
913 # }}}
914 # {{{ grep, xargs
915
916 alias -g G='| egrep'
917 alias -g EG='|& egrep'
918 alias -g X='| xargs'
919 alias -g X0='| xargs -0'
920 alias -g XG='| xargs egrep'
921 alias -g X0G='| xargs -0 egrep'
922
923 # }}}
924
925 # }}}
926
927 # }}}
928 # {{{ Key bindings 
929
930 zshrc_load_status 'key bindings'
931
932 bindkey -s '^X^Z' '%-^M'
933 bindkey '^[e' expand-cmd-path
934 #bindkey -s '^X?' '\eb=\ef\C-x*'
935 bindkey '^[^I' reverse-menu-complete
936 bindkey '^X^N' accept-and-infer-next-history
937 bindkey '^[p'  history-beginning-search-backward
938 bindkey '^[n'  history-beginning-search-forward
939 bindkey '^[P'  history-beginning-search-backward
940 bindkey '^[N'  history-beginning-search-forward
941 bindkey '^w'   kill-region-or-backward-word
942 bindkey '^[^W' kill-region-or-backward-big-word
943 bindkey '^I'   complete-word
944 bindkey '^Xi'  incremental-complete-word
945 # bindkey '^[b' emacs-backward-word
946 # bindkey '^[f' emacs-forward-word
947 bindkey '^[B'  backward-to-space
948 bindkey '^[F'  forward-to-space
949 bindkey '^[^b' backward-to-/
950 bindkey '^[^f' forward-to-/
951
952 bindkey '^[D'  kill-big-word
953
954 if zmodload zsh/deltochar >&/dev/null; then
955   bindkey '^[z' zap-to-char
956   bindkey '^[Z' delete-to-char
957 fi
958
959 # Fix weird sequence that rxvt produces
960 bindkey -s '^[[Z' '\t'
961
962 alias no=ls  # for Dvorak
963
964 # }}}
965 # {{{ Miscellaneous
966
967 zshrc_load_status 'miscellaneous'
968
969 # {{{ Hash named directories
970
971 # cdable_vars is set, so don't need 'hash -d' in front of these
972 RP=/usr/src/redhat/RPMS
973 I3=/usr/src/redhat/RPMS/i386
974 I4=/usr/src/redhat/RPMS/i486
975 I5=/usr/src/redhat/RPMS/i586
976 I6=/usr/src/redhat/RPMS/i686
977 NA=/usr/src/redhat/RPMS/noarch
978 SR=/usr/src/redhat/SRPMS
979 SP=/usr/src/redhat/SPECS
980 SO=/usr/src/redhat/SOURCES
981 BU=/usr/src/redhat/BUILD
982 LI=/usr/src/linux
983 L4=/usr/src/linux-2.4
984 CV=/usr/local/cvsroot
985 RC=/etc/rc.d/init.d
986 VL=/var/log
987 #hash -df
988
989 # }}}
990 # {{{ ls colours
991
992 if which dircolors >&/dev/null && [[ -e "${zdotdir}/.dircolors" ]]; then
993   eval "`dircolors -b $zdotdir/.dircolors`"
994 fi
995
996 if [[ $ZSH_VERSION > 3.1.5 ]]; then
997   zmodload -i zsh/complist
998
999   zstyle ':completion:*' list-colors ''
1000
1001   zstyle ':completion:*:*:kill:*:processes' list-colors \
1002     '=(#b) #([0-9]#)*=0=01;31'
1003
1004   # completion colours
1005   zstyle ':completion:*' list-colors "$LS_COLORS"
1006 fi  
1007
1008 # }}}
1009 # {{{ Don't always autologout
1010
1011 if [[ "${TERM}" == ([Ex]term*|dtterm|screen*) ]]; then
1012   unset TMOUT
1013 fi
1014
1015 # }}}
1016
1017 # }}}
1018
1019 # {{{ Specific to local setups
1020
1021 zshrc_load_status 'local hooks'
1022 run_local_hooks .zshrc
1023
1024 # }}}
1025
1026 # {{{ Clear up after status display
1027
1028 if [[ $TERM == tgtelnet ]]; then
1029   echo
1030 else
1031   echo -n "\r"
1032 fi
1033
1034 # }}}
1035 # {{{ Profile report
1036
1037 if [[ -n "$ZSH_PROFILE_RC" ]]; then
1038   zprof >! ~/zshrc.zprof
1039   exit
1040 fi
1041
1042 # }}}
1043
1044 # {{{ Search for history loosing bug
1045
1046 which check_hist_size >&/dev/null && check_hist_size
1047
1048 # }}}