initial checkin
[zsh-lovers.git] / zsh_people / arne_schwabes / zshrc
1 #!/bin/zsh
2 # I got this file from someone (don't remember who though) 
3 # and modified it :).
4 #
5 # Arne Schwabe <arne@rfc2549.org>
6 #
7 # But some credit still goes to (and others):
8 #
9 # zshrc - by trey tabner. email:  trey@epicsol.org   irc:  icetrey@efnet
10 # not all of this is mine, a few of the completions are taken from old examples :)
11
12 hosts=( news mailrapid mailgate mailgate2 mailserv \
13         leros atreus monkey-island \
14     ilum r2d2 kamino geonosis coruscant.rfc1149.org \
15         info-stud info-e info-f angkor-vat athene webserv \
16         naxos simon-the-sorcerer the-little-computer-project pissarro \
17         kevin feivel orang-utan-klaus \
18         queaker debian.ventourizen.de fireball \
19         debian.ventourizen.de queaker )
20
21 umask 022
22 alias dos2unix='recode ibmpc:lat1'
23 alias unix2dos='recode la1:imbpc'
24 alias dp=display
25 if [[ -e /usr/local/maple8-8.01/bin/ ]]; then
26         alias maple=/usr/local/maple8-8.01/bin/maple
27         alias xmaple=/usr/local/maple8-8.01/bin/xmaple
28 fi
29
30 #alias kernel='finger @finger.kernel.org'
31
32 alias j='jobs -l'
33 alias h='history'
34
35 lynx='lynx -accept_all_cookies'
36
37 alias lowercase='for i in [A-Z][A-Z]*(.); do mv "$i" "${i:l}" ;done'
38 alias bt='PORT=$RANDOM; btdownloadcurses.py --max_upload_rate 3 --minport $(($PORT+1400)) --maxport $(($PORT + 1410))'
39 alias btu='PORT=$RANDOM; btdownloadcurses.py --max_upload_rate 100 --minport $(($PORT+1400)) --maxport $(($PORT + 1410))'
40 alias bto='PORT=$RANDOM; btdownloadcurses.py --max_upload_rate 13 --minport $(($PORT+1400)) --maxport $(($PORT + 1410))'
41 alias mgqueue='ssh mailgate /home/mail/exim/bin/exim -C /home/mail/exim/configure.outgoing -bpc'
42 alias acroread="LANG=de_DE acroread"
43
44 export HISTFILE=$HOME/.zshhistory
45 export HISTSIZE=10000
46 export SAVEHIST=5000
47
48 export EDITOR=emacs
49 export PAGER=less
50
51 export LANG=de_DE.UTF-8
52 export LC_MESSAGES=C
53
54 setopt \
55         NO_all_export \
56         always_last_prompt \
57         NO_always_to_end \
58         append_history \
59         NO_auto_cd \
60         auto_list \
61         auto_menu \
62         NO_auto_name_dirs \
63         auto_param_keys \
64         auto_param_slash \
65         auto_pushd \
66         auto_remove_slash \
67         NO_auto_resume \
68         bad_pattern \
69         bang_hist \
70         NO_beep \
71         bg_nice \
72         brace_ccl \
73                 bsd_echo \
74         correct_all \
75         cdable_vars \
76         NO_chase_links \
77         no_clobber \
78         complete_aliases \
79         complete_in_word \
80         correct \
81         NO_correct_all \
82         csh_junkie_history \
83         NO_csh_junkie_loops \
84         NO_csh_junkie_quotes \
85         NO_csh_null_glob \
86         equals \
87         extended_glob \
88         extended_history \
89         function_argzero \
90         glob \
91         NO_glob_assign \
92         glob_complete \
93         glob_dots \
94         glob_subst \
95         hash_cmds \
96         hash_dirs \
97         hash_list_all \
98         NO_hist_allow_clobber \
99         NO_hist_beep \
100         hist_ignore_dups \
101         hist_ignore_space \
102         hist_no_store \
103         no_hist_verify \
104         NO_hup \
105         NO_ignore_braces \
106         NO_ignore_eof \
107         interactive_comments \
108         NO_list_ambiguous \
109         NO_list_beep \
110         list_types \
111         long_list_jobs \
112         magic_equal_subst \
113         NO_mail_warning \
114         NO_mark_dirs \
115         NO_menu_complete \
116         multios \
117         nomatch \
118         notify \
119         NO_null_glob \
120         numeric_glob_sort \
121         NO_overstrike \
122         path_dirs \
123         posix_builtins \
124         print_exit_value \
125         NO_prompt_cr \
126         prompt_subst \
127         pushd_ignore_dups \
128         NO_pushd_minus \
129         NO_pushd_silent \
130         pushd_to_home \
131         rc_expand_param \
132         NO_rc_quotes \
133         NO_rm_star_silent \
134         NO_sh_file_expansion \
135             sh_option_letters \
136                 no_sh_glob \
137         short_loops \
138         NO_sh_word_split \
139         NO_single_line_zle \
140         NO_sun_keyboard_hack \
141         unset \
142         NO_verbose \
143         NO_xtrace \
144         zle
145
146
147
148 # From zefram Prompt and heavily modified (you did not expect anything else, did you)
149 # The screen and preexec thing came from www.zshwiki.org/cgi-bin/wiki.pl?ZshHardStatus
150
151  case $TERM in
152          xterm*)
153                  function title () {print -nP '\e]0;'$*'\a'}
154          ;;
155          screen*)
156                  function title () {
157                    print -nPR $'\033k'$1$'\033'\\ 
158                    print -nPR $'\033]0;'$2$'\a'
159                    }
160                  ;;
161          *)
162                  function title() {}
163                  ;;
164                  
165  esac
166
167
168 function prompt_arne_zefram_precmd {
169         local exitstatus=$?
170         psvar=(SIG)
171         [[ $exitstatus -gt 128 ]] && psvar[1]=SIG$signals[$exitstatus-127]
172         [[ $psvar[1] = SIG ]] && psvar[1]=$exitstatus
173         jobs % >/dev/null 2>&1 && psvar[2]=
174
175                 title "%n@%m:%20<...<%3~%<<"
176 }
177
178 function prompt_arne_zefram_setup {
179   PS1='[%(00t.DING%(0T. DONG.)!.%T)]%(?..%U{%v}%u)%(!..%n%(2v.%B@%b.@))%m:%20<...<%3~%<<%# '
180   PS2='%(4_:... :)%3_> '
181
182   prompt_opts=( cr subst percent )
183   precmd () { prompt_arne_zefram_precmd }
184   function preexec {
185       emulate -L zsh
186       local -a cmd; cmd=(${(z)1})
187       title %n@%m:$cmd[1]:t "$cmd[2,-1]"
188   }
189 }
190
191 function prompt_arne_zefram_setup3 {
192         prompt_arne_zefram_setup
193         function preexec() {}
194 }
195
196 if [[ $USER != root ]]; then
197     if [[ "$SSH_AUTH_SOCK" == "" && -f ~/.ssh/.agent-$HOST ]]; then
198         echo -n "Reused PID: "
199         source ~/.ssh/.agent-$HOST
200     fi
201
202
203     ssh-add -l  2> /dev/null # | cut -d" " -f1,3,4
204
205     if [[ $? == 1 || $? == 0 ]] then
206         #echo ssh agent reused
207         :
208     else
209         if [[ -f ~/.ssh/.agent-$HOST ]]; then
210             rm ~/.ssh/.agent-$HOST
211         fi
212         ssh-agent > ~/.ssh/.agent-$HOST
213         source ~/.ssh/.agent-$HOST
214     fi
215     unset tmp
216 fi
217
218 if [[ $OSTYPE = 'linux-gnu' ]]; then
219         filesystems="${${(f)$(</proc/filesystems)}#*  }"
220         eval "$(dircolors)"
221         setterm -hbcolor bright white
222         setterm -ulcolor cyan
223
224         alias ls='ls --color=auto'
225         alias df='df -T'
226         
227
228         # FreeBSD seems to be more clever, so I move this to Linux
229         export PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
230         if [ -d ~/bin ]; then
231            PATH="$HOME/bin:${PATH}"
232         fi
233
234         # Sigh, I have far _too_ many GNUism in my config
235 elif test `uname` = 'FreeBSD'; then
236         # No PATH setting :)))
237         alias ls='ls -GF'
238
239
240         
241         function temp () {
242                 echo $(($(sysctl hw.acpi.thermal.tz0.temperature \
243                         | cut -d " " -f 2) / 10.0 - 273.15))
244         }
245 elif test `uname` = 'SunOS'; then
246         PATH=/usr/sbin/:/usr/bin
247         if [ -e /usr/pkg ]; then
248                 PATH=${PATH}:/usr/pkg/bin:/usr/pkg/sbin
249                 MANPATH=${MANPATH}:/usr/pkg/man
250         fi
251         PATH=${PATH}:/opt/SUNWspro/bin
252         PATH=${PATH}:/usr/local/bin
253         PATH=${PATH}:/usr/ccs/bin/:usr/ccs/lib
254         PATH=${PATH}:/opt/sfw/bin
255
256         if [ "DISPLAY" != "" ]; then
257                 PATH=${PATH}:/usr/dt/bin
258                 PATH=${PATH}:/usr/openwin/bin
259         fi
260         export PATH
261 fi
262
263
264 if [[ $HOST == "coruscant" ]]; then
265         export CVSROOT="/var/lib/cvs"
266 else
267         export CVSROOT=":pserver:arne@coruscant.rfc1149.org:/var/lib/cvs"
268 fi
269
270         
271 if test $HOST = "mailrapid" || test $HOST = "mailgate"  || test $HOST = "mailgate2" || test $HOST = "mailrapid2"  ; then
272         export PATH=/home/mail/bin:$PATH
273         if test $HOST = "mailrapid" ; then
274                 export PATH=$PATH:/var/mailman/bin
275         fi
276 fi
277
278
279
280 bindkey -me
281 bindkey -s '^X^Z' '%-^M'
282 bindkey '^[e' expand-cmd-path
283 bindkey -s '^X?' '\eb=\ef\C-x*'
284 bindkey '^[^I' reverse-menu-complete
285 bindkey '^[p' history-beginning-search-backward
286 bindkey '^[n' history-beginning-search-forward
287
288 bindkey '^p' history-beginning-search-backward
289 bindkey '^n' history-beginning-search-forward
290 bindkey '^[[A' history-beginning-search-backward
291 bindkey '^[[B' history-beginning-search-forward
292
293 bindkey '^W' kill-region
294 bindkey '^I' expand-or-complete-prefix
295 bindkey -s '^[[Z' '\t'
296
297
298 bindkey "\e[4~" end-of-line
299 bindkey "^[[8~"  end-of-line
300
301 bindkey "^[[1~" beginning-of-line
302 bindkey "^[[7~" beginning-of-line
303
304 if [[ ${ZSH_VERSION%%.*} -ge 4 ]]; then
305         zstyle :compinstall filename '/home/arne/.zshrc'
306         zstyle '*' hosts $hosts
307         prompt_arne_zefram_setup
308
309         autoload -U compinit
310         compinit
311         
312 #       setopt \
313 #               share_history
314  else 
315         prompt_arne_zefram_setup3
316 fi
317
318 ## Orginal Source Code of the Clock:
319 ## Thomas Köhler also has a .zshrc: http://gott-gehabt.de/800_wer_wir_sind/thomas/Homepage/Computer/zsh/u
320 # Modified to fit to my prompt
321 # Does not work so good :/
322
323 #trap uhrzeit ALRM
324 #TMOUT=60
325
326 #function uhrzeit() {
327 #   print -nP "\e7\e[1;G"
328 #   # echo the date
329 #   print -nP "[%(00t.DING%(0T. DONG.)!.%T)]"
330 #   # restore cursor position
331 #   print -nP "\e8"
332 #}
333
334
335
336
337
338 function kernel()
339 {
340         printf 'GET /kdist/finger_banner HTTP1.0\n\n' | nc www.kernel.org 80 | grep latest
341 }
342
343 function http_header()
344 {
345        # This is zsh but still no gnu echoism ;P
346        if [[ $2 != "" ]] { port=$2 } else { port=80 }
347        if [[ $3 != "" ]] { vhost="$3" } else { vhost=$1 }
348  
349        printf "HEAD /$4 HTTP/1.1\\nHost: $vhost\nConnection: close\n\n" \
350         | nc $1 $port
351 }
352
353
354 function setenv() { export $1="$2" }
355 function unsetenv() { unset $1 }
356
357