initial checkin
[zsh-lovers.git] / zsh_people / damien_elmes / zshrc
1 #!/usr/bin/zsh
2 # -*- mode: shell-script -*-
3 #
4 # .zshrc - customisations for the all-powerful shell
5 #
6 # the latest copy of this file can be found at 
7 #   http://repose.cx/conf
8 #
9
10 typeset -U path
11 path=(~/.bin ~/Muse /sbin /usr/sbin $path)
12
13 typeset -U cdpath
14 cdpath=(. $cdpath)
15
16 setopt nobeep                  # i hate beeps
17 setopt noautomenu              # don't cycle completions
18 setopt autocd                  # change to dirs without cd
19 #setopt autopushd               # automatically append dirs to the push/pop list
20 setopt pushdignoredups         # and don't duplicate them
21 setopt cdablevars              # avoid the need for an explicit $
22 setopt nocheckjobs             # don't warn me about bg processes when exiting
23 setopt nohup                   # and don't kill them, either
24 #setopt listpacked              # compact completion lists
25 setopt nolisttypes             # show types in completion
26 setopt dvorak                  # with spelling correction, assume dvorak kb
27 setopt extendedglob            # weird & wacky pattern matching - yay zsh!
28 setopt completeinword          # not just at the end
29 setopt alwaystoend             # when complete from middle, move cursor
30 setopt correct                 # spelling correction
31 setopt nopromptcr              # don't add \n which overwrites cmds with no \n
32 setopt histverify              # when using ! cmds, confirm first
33 setopt interactivecomments     # escape commands so i can use them later
34 setopt printexitvalue          # alert me if something's failed
35
36 # woo! so glad i found this. jump to each element in a path with m-f m-b, same
37 # for kill-word, etc.
38 export WORDCHARS=''            
39
40 # history related stuff.
41 export HISTSIZE=5000
42 export SAVEHIST=5000
43 export HISTFILE=~/.zsh_history
44 setopt hist_ignore_dups        # ignore same commands run twice+
45 setopt appendhistory           # don't overwrite history 
46
47 # prompt (if running screen, show window #)
48 if [ x$WINDOW != x ]; then
49     export PS1="%m[$WINDOW]%# "
50 else
51     export PS1='%m%# '
52 fi
53
54 # set up some directory variables. i can then do cd ms to land in my music dir
55 # emacs understands these too.
56 export m=~/Media/music
57 export uni=~/Lib/uni
58 export code=~/Lib/code
59 export work=~/Lib/work
60 : ~m ~uni ~code ~work
61
62 # preexec hook shows command in title as it's running, and precmd sets it to
63 # something else when it's done. this should work with screen and
64 # gnome-terminal2/multi-gnome-terminal
65
66 case $TERM in
67     xterm*|screen*)
68         preexec () {
69             export CURRENTCMD="$1"
70             if [ x$WINDOW != x ]; then
71                 print -Pn "\ek$1\e\\"
72             else
73                 print -Pn "\e]0;$1\a"
74             fi
75         }
76         precmd () {
77             if [[ ! -z $CURRENTCMD ]]; then
78                 if [ x$WINDOW != x ]; then
79                     print -Pn "\ek($CURRENTCMD)\e\\"
80                 else
81                     print -Pn "\e]0;($CURRENTCMD)\a"
82                 fi
83             fi
84         }
85     ;;
86 esac
87
88 # log out all my ephemeral shells, except the last one
89 export TMOUT=60
90
91 TRAPALRM () {
92     if [ `pwd` = ~ ] && [ x$WINDOW != x ] && (( $WINDOW != 0 )); then
93         exit 0
94     fi
95 }
96
97 [[ "$WINDOW" = 0 ]] && setopt ignore_eof
98
99 #trap '(( $WINDOW == 0 )) && echo "Last window - type logout" && return 0' EXIT
100
101 # this is defined in ~/.bin/e now
102
103 # i have gnuclient set to load files in my current emacs buffer, so i'd like to
104 # jump to it afterwards. i use a program "e" to edit files in this manner.
105 # e() {
106 #     sawfish-client -f de-gnuserv-activate > /dev/null
107 #     # now run gnuclient. we'll be returned to this window when c-x # is hit in
108 #     # emacs
109 #     gnuclient $1
110 # }
111
112 export CVSROOT=~/Lib/CVS
113
114
115 # If running interactively, then:
116 if [ "$PS1" ]; then
117     # colour ls
118     eval `dircolors`
119     alias ls='ls --color=auto'
120     
121     # use ssh for rysnc
122     export RSYNC_RSH=ssh
123
124     # used to have arch-dependent flags, but i kept forgetting to unset cflags
125     # before compiling stuff for another box. i don't compile much anymore.
126     export CFLAGS="-O2 -fomit-frame-pointer -pipe"
127
128     export SmallEiffel="/usr/lib/smalleiffel/sys/system.se"
129     export PYTHONPATH="/home/resolve/.python"
130     export PYTHONSTARTUP="/home/resolve/.pystartup"
131     export SAVEDIR="/home/resolve/.news/"
132     export ORGANISATION="Damien Elmes"
133
134     export TEXINPUTS=::/usr/local/lib/texmf
135
136     export VISUAL=e
137     export EDITOR=$VISUAL
138
139     # colours in man output, emacs like bindings. nifty.
140     export PAGER=most
141
142     # anti aliasing in the two toolkits
143     export QT_XFT=1
144     export GDK_USE_XFT=1
145
146     alias go-wl="sudo ifdown eth0; sudo /etc/init.d/pcmcia start"
147     alias go-eth="sudo /etc/init.d/pcmcia stop; sudo ifup eth0" 
148     alias nw="sfsagent resolve@respite; ls .mail > /dev/null 2>&1"
149     
150     # display reminders
151     [ -f .r ] && cat .r
152
153     umask 022
154
155 #
156 # completion tweaking
157 #
158
159 # complete hostnames out of ssh's ~/.ssh/known_hosts
160     autoload -U compinit; compinit
161     zstyle ':completion:*' use-cache on
162     zstyle ':completion:*' users resolve
163     hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
164     zstyle ':completion:*:hosts' hosts $hosts
165
166 # use dircolours in completion listings
167     zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
168
169 # allow approximate matching
170     zstyle ':completion:*' completer _complete _match _approximate
171     zstyle ':completion:*:match:*' original only
172     zstyle ':completion:*:approximate:*' max-errors 1 numeric
173     zstyle ':completion:*' auto-description 'Specify: %d'
174     zstyle ':completion:*' format 'Completing %d'
175     zstyle ':completion:*' verbose true
176     zstyle ':completion:*:functions' ignored-patterns '_*'
177     zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns \
178         '*?.(o|c~|zwc)' '*?~'
179
180     bindkey "\C-w" kill-region
181
182 fi
183
184 # evaluate work related stuff
185 [ -f .workrc ] && . ~/.workrc
186
187 if [ x$TERM = xscreen ]; then
188     export TERM=xterm
189 fi