1 # $Id: .zshrc,v 1.61 2006/07/25 07:58:31 jdq Exp jdq $
  2 typeset -U path
  3 path=(~/bin ~/local/bin /sbin /usr/sbin $path)
  4 manpath=(~/local/man $manpath)
  5 
  6 ## (( ${+*} )) = if variable is set don't set it anymore
  7 (( ${+USER} )) || export USER=$USERNAME
  8 (( ${+HOSTNAME} )) || export HOSTNAME=$HOST
  9 (( ${+EDITOR} )) || export EDITOR=`which vim`
 10 (( ${+VISUAL} )) || export VISUAL=`which vim`
 11 (( ${+FCEDIT} )) || export FCEDIT=`which vim`
 12 (( ${+PAGER} )) || export PAGER=`which less`
 13 (( ${+LESSOPEN} )) || export LESSOPEN='|lesspipe.sh %s'
 14 (( ${+NNTPSERVER} )) || export NNTPSERVER='news.t-online.de'
 15 (( ${+CC} )) || export CC='gcc'
 16 
 17 #hier abbrechen falls die shell nicht interaktiv ist
 18 if [ ! "$PS1" ]; then
 19     break
 20 fi
 21 
 22 #if [ -e ~/.mails ]; then
 23 #   mailpath=( )
 24 #   for i in ~/.mails/*; do
 25 #       mailpath[$#mailpath+1]="${i}?You have new mail in ${i:t}."
 26 #   done
 27 #fi
 28 
 29 typeset -U cdpath
 30 cdpath=(. $cdpath)
 31 
 32 if [ -f ~/.gentoo/java-env ]; then
 33     source ~/.gentoo/java-env
 34 fi
 35 
 36 if [ -f ~/.aliases ]; then
 37      source ~/.aliases
 38 fi
 39 
 40 #bindkey -v               # vi key bindings
 41 bindkey "^r" history-incremental-search-backward
 42 
 43 bindkey -e                 # emacs key bindings
 44 bindkey ' ' magic-space    # also do history expansion on space
 45 bindkey '^I' complete-word # complete on tab, leave expansion to _expand
 46 
 47 bindkey "[A" history-beginning-search-backward
 48 bindkey "[B" history-beginning-search-forward
 49 bindkey "[C" forward-char
 50 bindkey "[D" backward-char
 51 bindkey "^Xq" push-line
 52 bindkey "^Xr" history-incremental-search-backward
 53 bindkey "^Xs" history-incremental-search-forward
 54 bindkey "^X_" insert-last-word
 55 bindkey "^Xa" accept-and-hold
 56 bindkey "^X^H" run-help
 57 bindkey "^Xh" _complete_help
 58 bindkey "^I" expand-or-complete
 59 #bindkey "^E" expand-word
 60 bindkey "^E" end-of-line
 61 bindkey "^N" menu-complete
 62 bindkey "^P" reverse-menu-complete
 63 bindkey -M vicmd "^R" redo
 64 bindkey -M vicmd "u" undo
 65 bindkey -M vicmd "ga" what-cursor-position
 66 
 67 #
 68 #### VI MODE EXTENSIONS
 69 #redisplay() {
 70 #   builtin zle .redisplay
 71 #   ( true ; show_mode "INSERT") &!
 72 #}
 73 #redisplay2() {
 74 #   builtin zle .redisplay
 75 #   (true ; show_mode "NORMAL") &!
 76 #}
 77 #zle -N redisplay
 78 #zle -N redisplay2
 79 #bindkey -M viins "^X^R" redisplay
 80 #bindkey -M vicmd "^X^R" redisplay2
 81 #
 82 #show_mode() {
 83 #   local x
 84 #   local y
 85 #   local buflines
 86 #   x=$(echo $PREBUFFER | wc -l )
 87 #   x=$(echo $PREDISPLAY | wc -l )
 88 #   buflines=$(echo $LBUFFER | wc -l)
 89 #   x=$[x + buflines - 1]
 90 #   y=$[11 + $(echo $HOSTNAME |awk -F. '{print $1}'| wc -m ) + $(echo $USER | wc -m) + $(echo $TTY | wc -m)]
 91 #   if [ $x -eq 1 ]; then
 92 #           echo -n "\e7\e[;A"
 93 #   else
 94 #       echo -n "\e7\e[$x;A"
 95 #   fi
 96 #   echo -n "^[[$y;G"
 97 #   echo -n ""
 98 #   echo -n "^[[0;37;44m--$1--^[[0m"
 99 #   echo -n "^[8"
100 #}
101 #
102 ####       vi-add-eol (unbound) (A) (unbound)
103 ####              Move  to the end of the line and enter insert mode.
104 #
105 #vi-add-eol() {
106 #   show_mode "INSERT"
107 #   builtin zle .vi-add-eol
108 #}
109 #zle -N vi-add-eol
110 #bindkey -M vicmd "A" vi-add-eol
111 #
112 ####       vi-add-next (unbound) (a) (unbound)
113 ####              Enter insert mode after the  current  cursor  posi­
114 ####              tion, without changing lines.
115 #
116 #vi-add-next() {
117 #   show_mode "INSERT"
118 #   builtin zle .vi-add-next
119 #}
120 #zle -N vi-add-next
121 #bindkey -M vicmd "a" vi-add-next
122 #
123 #vi-change() {
124 #   show_mode "INSERT"
125 #   builtin zle .vi-change
126 #}
127 #zle -N vi-change
128 #bindkey -M vicmd "c" vi-change
129 #
130 ####       vi-change-eol (unbound) (C) (unbound)
131 ####              Kill  to the end of the line and enter insert mode.
132 #
133 #vi-change-eol() {
134 #   show_mode "INSERT"
135 #   builtin zle .vi-change-eol
136 #}
137 #zle -N vi-change-eol
138 #bindkey -M vicmd "C" vi-change-eol
139 #
140 ####       vi-change-whole-line (unbound) (S) (unbound)
141 ####              Kill the current line and enter insert mode.
142 #
143 #vi-change-whole-line() {
144 #   show_mode "INSERT"
145 #   builtin zle .vi-change-whole-line
146 #}
147 #zle -N vi-change-whole-line
148 #bindkey -M vicmd "S" vi-change-whole-line
149 #
150 ####       vi-insert (unbound) (i) (unbound)
151 ####              Enter insert mode.
152 #
153 #vi-insert() {
154 #   show_mode "INSERT"
155 #   builtin zle .vi-insert
156 #}
157 #zle -N vi-insert
158 #bindkey -M vicmd "i" vi-insert
159 #
160 ####       vi-insert-bol (unbound) (I) (unbound)
161 ####              Move to the first non-blank character on  the  line
162 ####              and enter insert mode.
163 #
164 #vi-insert-bol() {
165 #   show_mode "INSERT"
166 #   builtin zle .vi-insert-bol
167 #}
168 #zle -N vi-insert-bol
169 #bindkey -M vicmd "I" vi-insert-bol
170 #
171 ####       vi-open-line-above (unbound) (O) (unbound)
172 ####              Open a line above the cursor and enter insert mode.
173 #
174 #vi-open-line-above() {
175 #   show_mode "INSERT"
176 #   builtin zle .vi-open-line-above
177 #}
178 #zle -N vi-open-line-above
179 #bindkey -M vicmd "O" vi-open-line-above
180 #
181 ####       vi-open-line-below (unbound) (o) (unbound)
182 ####              Open a line below the cursor and enter insert mode.
183 #
184 #vi-open-line-below() {
185 #   show_mode "INSERT"
186 #   builtin zle .vi-open-line-below
187 #}
188 #zle -N vi-open-line-below
189 #bindkey -M vicmd "o" vi-open-line-below
190 #
191 ####       vi-substitute (unbound) (s) (unbound)
192 ####              Substitute the next character(s).
193 #
194 #vi-substitute() {
195 #   show_mode "INSERT"
196 #   builtin zle .vi-substitute
197 #}
198 #zle -N vi-substitute
199 #bindkey -M vicmd "s" vi-substitute
200 #
201 #
202 ####       vi-replace (unbound) (R) (unbound)
203 ####              Enter overwrite mode.
204 ####
205 #
206 #vi-replace() {
207 #   show_mode "REPLACE"
208 #   builtin zle .vi-replace
209 #}
210 #zle -N vi-replace
211 #bindkey -M vicmd "R" vi-replace
212 #
213 ####       vi-cmd-mode (^X^V) (unbound) (^[)
214 ####              Enter  command  mode;  that  is, select the `vicmd'
215 ####              keymap.  Yes, this is bound  by  default  in  emacs
216 ####              mode.
217 #
218 #vi-cmd-mode() {
219 #   show_mode "NORMAL"
220 #   builtin zle .vi-cmd-mode
221 #}
222 #zle -N vi-cmd-mode
223 #bindkey -M viins "^[" vi-cmd-mode
224 
225 case $TERM in
226     linux|screen)
227     bindkey "^[[2~" yank
228     bindkey -M vicmd "^[[2~" yank
229     bindkey "^[[3~" delete-char
230     bindkey -M vicmd "^[[3~" delete-char
231     bindkey "^[[5~" up-line-or-history ## PageUp
232     bindkey -M vicmd "^[[5~" up-line-or-history ## PageUp
233     bindkey "^[[6~" down-line-or-history ## PageDown
234     bindkey -M vicmd "^[[6~" down-line-or-history ## PageDown
235     bindkey "^[[1~" beginning-of-line
236     bindkey -M vicmd "^[[1~" beginning-of-line
237     bindkey "^[[4~" end-of-line
238     bindkey -M vicmd "^[[4~" end-of-line
239     bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command
240     bindkey -M vicmd "^[e" expand-cmd-path ## C-e for expanding path of typed command
241     bindkey "^[[A" up-line-or-search ## up arrow for back-history-search
242     bindkey -M vicmd "^[[A" up-line-or-search ## up arrow for back-history-search
243     bindkey "^[[B" down-line-or-search ## down arrow for fwd-history-search
244     bindkey -M vicmd "^[[B" down-line-or-search ## down arrow for fwd-history-search
245     bindkey " " magic-space ## do history expansion on space
246     bindkey -M vicmd " " magic-space ## do history expansion on space
247 ;;
248     *xterm*|rxvt|(dt|k|E)term)
249     bindkey "^[[2~" yank
250     bindkey -M vicmd "^[[2~" yank
251     bindkey "^[[3~" delete-char
252     bindkey -M vicmd "^[[3~" delete-char
253     bindkey "^[[5~" up-line-or-history ## PageUp
254     bindkey -M vicmd "^[[5~" up-line-or-history ## PageUp
255     bindkey "^[[6~" down-line-or-history ## PageDown
256     bindkey -M vicmd "^[[6~" down-line-or-history ## PageDown
257     bindkey "^[[7~" beginning-of-line
258     bindkey -M vicmd "^[[7~" beginning-of-line
259     bindkey "^[[8~" end-of-line
260     bindkey -M vicmd "^[[8~" end-of-line
261     bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command
262     bindkey -M vicmd "^[e" expand-cmd-path ## C-e for expanding path of typed command
263     bindkey "^[[A" up-line-or-search ## up arrow for back-history-search
264     bindkey -M vicmd "^[[A" up-line-or-search ## up arrow for back-history-search
265     bindkey "^[[B" down-line-or-search ## down arrow for fwd-history-search
266     bindkey -M vicmd "^[[B" down-line-or-search ## down arrow for fwd-history-search
267     bindkey " " magic-space ## do history expansion on space
268     function title {
269        # Use this one instead for XTerms:
270        print -nR $'\033]0;'$*$'\a'
271     }
272 
273     function precmd {
274         title "$USER@$HOSTNAME"
275     }
276 
277     function preexec {
278         emulate -L zsh
279         local -a cmd; cmd=(${(z)1})
280         title $cmd[1]:t "$cmd[2,-1]"
281     }
282     ;;
283 
284     # Use these two for GNU Screen:
285     screen*)
286     function title {
287             print -nR $'\033k'$1$'\033'\\
288             print -nR $'\033]0;'$2$'\a'
289     }
290 
291 ;;
292 esac
293 
294 
295 HISTFILE=~/.zsh/history
296 HISTSIZE=3000
297 SAVEHIST=3000
298 
299 # restore dirstack
300 DIRSTACKSIZE=20
301 if [[ -f ~/.zsh/dirs ]] && [[ ${#dirstack[*]} -eq 0 ]]; then
302     dirstack=( ${(uf)"$(< ~/.zsh/dirs)"} )
303 fi
304 chpwd() {
305     if [[ -f ~/.zsh/dirs ]] then
306         dirstack=( ${(uf)"$(< ~/.zsh/dirs)"} )
307     fi
308     dir=`dirs -pl`
309     dirc=`echo $dir | sed q`
310     #dirc=`pwd`
311     raute=`echo $dir | sed 's/\//#/g'`
312     tmp=`echo ${raute} | sed "/${dirc//\//#}\$/d"`
313     #echo $dirc >! ~/.zsh/dirs
314     #result=`echo $dirc; echo ${tmp//\#/\/}`
315     #result=`echo $dirc; echo $dir`
316     echo ${dir} > ~/.zsh/dirs
317     echo ${tmp//\#/\/} >> ~/.zsh/dirs
318 }
319 
320 # {{{ Watching for other users
321 
322 LOGCHECK=60
323 WATCHFMT="[%B%t%b] %B%n%b has %a %B%l%b from %B%M%b"
324 watch=(notme)
325 
326 # }}}
327 
328 # always alias vi to vim
329 if which vim >&/dev/null; then
330   alias vi='vim -X'
331 fi
332 
333 # {{{ Don't always autologout
334 
335 if [[ "${TERM}" == ([Ex]term*|dtterm|screen*) ]]; then
336   unset TMOUT
337 fi
338 
339 # }}}
340 
341 # {{{ Common hostnames
342 
343 if [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
344 : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
345 else
346 # Older versions don't like the above cruft
347   _etc_hosts=()
348 fi
349   hosts=(
350   "$_etc_hosts[@]"
351   localhost
352 )
353 zstyle ':completion:*' hosts $hosts
354 # }}}
355 
356 # {{{ (user,host) pairs
357 
358 # All my accounts:
359 my_accounts=(
360   {root,jdq}@{rincewind,twoflower,jdq.ath.cx,blop,albert}
361   {root,jdq,fsinfo}@{hobbes,calvin,susi}
362   {jdq,fsinfo}@{taifun,hurrikan,jaufen,agnel,orkan,gavia,dangast}
363   {jdq,syspect}@{manjula,wendell,lisa,skinner,zola}
364 )
365 
366 zstyle ':completion:*:my-accounts' users-hosts $my_accounts
367 #zstyle ':completion:*:scp:*' menu yes select
368 
369 # }}}
370 
371 zstyle ':completion:*' use-cache on
372 zstyle ':completion:*' cache-path ~/.zsh/cache
373 
374 zstyle ':completion:*:rm:*' ignore-line yes
375 zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
376 zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
377 zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)scp'
378 zstyle ':completion:*:cd:*' ignored-patterns '(*/)#scp'
379 zstyle ':completion:*:cd:*' ignore-parents parent pwd
380 
381 # Insert all expansions for expand completer.
382 zstyle ':completion:*:expand:*' tag-order all-expansions
383 
384 # Formatting and messages (more verbose output...)
385 zstyle ':completion:*' verbose yes
386 zstyle ':completion:*:descriptions' format '%B%d%b'
387 zstyle ':completion:*:messages' format '%d'
388 zstyle ':completion:*:warnings' format 'No matches for: %d'
389 zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
390 zstyle ':completion:*' group-name ''
391 
392 zstyle ':completion:*:processes' command 'ps -au$USER'
393 zstyle ':completion:*:*:kill:*' menu yes select
394 zstyle ':completion:*:kill:*' force-list always
395 zstyle ':completion:*:functions' ignored-patterns '_*'
396 
397 zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
398 zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
399 
400 # match uppercase from lowercase
401 zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
402 
403 setopt nobeep                  # i hate beeps
404 setopt autocd                  # change to dirs without cd
405 setopt autopushd               # automatically append dirs to the push/pop list
406 setopt pushdignoredups         # and don't duplicate them
407 setopt nocheckjobs             # don't warn me about bg processes when exiting
408 setopt nohup                   # and don't kill them, either
409 setopt listpacked              # compact completion lists
410 setopt nolisttypes             # show types in completion
411 #setopt dvorak                  # with spelling correction, assume dvorak kb
412 setopt extendedglob            # weird & wacky pattern matching - yay zsh!
413 setopt completeinword          # not just at the end
414 setopt alwaystoend             # when complete from middle, move cursor
415 setopt correct                 # spelling correction
416 setopt nopromptcr              # don't add \r which overwrites output of cmds with no \n
417 setopt interactivecomments     # escape commands so i can use them later
418 setopt recexact                # recognise exact, ambiguous matches
419 setopt printexitvalue          # alert me if something's failed
420 setopt histverify              # when using ! cmds, confirm first
421 setopt hist_ignore_dups        # ignore same commands run twice+
422 setopt appendhistory           # don't overwrite history 
423 setopt share_history           # _all_ zsh sessions share the same history files
424 setopt hist_ignore_space       # ignore commands that have a leading space
425 
426 # only java files for javac
427 zstyle ':completion:*:javac:*' files '*.java'
428 # no binary files for vi
429 zstyle ':completion:*:vi:*' ignored-patterns '*.(o|a|so|aux|dvi|log|swp|fig|bbl|blg|bst|idx|ind|out|toc|class|pdf|ps)'
430 zstyle ':completion:*:vim:*' ignored-patterns '*.(o|a|so|aux|dvi|log|swp|fig|bbl|blg|bst|idx|ind|out|toc|class|pdf|ps)'
431 zstyle ':completion:*:gvim:*' ignored-patterns '*.(o|a|so|aux|dvi|log|swp|fig|bbl|blg|bst|idx|ind|out|toc|class|pdf|ps)'
432 # no binary files for less
433 zstyle ':completion:*:less:*' ignored-patterns '*.(o|a|so|dvi|fig|out|class|pdf|ps)'
434 zstyle ':completion:*:zless:*' ignored-patterns '*.(o|a|so|dvi|fig|out|class|pdf|ps)'
435 # pdf for xpdf
436 zstyle ':completion:*:xpdf:*' files '*.pdf'
437 # tar files
438 zstyle ':completion:*:tar:*' files '*.tar|*.tgz|*.tz|*.tar.Z|*.tar.bz2|*.tZ|*.tar.gz'
439 # latex to the fullest
440 # for printing
441 zstyle ':completion:*:xdvi:*' files '*.dvi'
442 zstyle ':completion:*:dvips:*' files '*.dvi'
443 
444 # completion
445 autoload -U compinit
446 compinit
447 
448 ## Color completion
449 ## this module should be automatically loaded if u use menu selection
450 ## but to be sure we do it here
451 zmodload -i zsh/complist
452 
453 ZLS_COLORS=$LS_COLORS
454 
455 ## This allows incremental completion of a word.
456 ## After starting this command, a list of completion
457 ## choices can be shown after every character you
458 ## type, which you can delete with ^h or DEL.
459 ## RET will accept the completion so far.
460 ## You can hit TAB to do normal completion, ^g to            
461 ## abort back to the state when you started, and ^d to list the matches.
462 autoload -U incremental-complete-word
463 zle -N incremental-complete-word
464 bindkey "^Xi" incremental-complete-word ## C-x-i
465 
466 ## This function allows you type a file pattern,
467 ## and see the results of the expansion at each step.
468 ## When you hit return, they will be inserted into the command line.
469 autoload -U insert-files
470 zle -N insert-files
471 bindkey "^Xf" insert-files ## C-x-f
472 
473 case $TERM in
474     xterm*|screen*)
475         preexec () {
476             export CURRENTCMD="$1"
477             if [ x$WINDOW != x ]; then
478                 print -Pn "\ek$1\e\\"
479             else
480                 print -Pn "\e]0;$1\a"
481             fi
482         }
483         precmd () {
484             if [[ ! -z $CURRENTCMD ]]; then
485                 if [ x$WINDOW != x ]; then
486                     print -Pn "\ek($CURRENTCMD)\e\\"
487                 else
488                     print -Pn "\e]0;($CURRENTCMD)\a"
489                 fi
490             fi
491         }
492     ;;
493 esac
494 
495 function cd () {
496   if [[ -z $2 ]]; then
497     if [[ -f $1 ]]; then
498       builtin cd $1:h
499     else
500       builtin cd $1
501     fi
502   else
503     if [[ -z $3 ]]; then
504       builtin cd $1 $2
505     else
506       echo cd: too many arguments
507     fi
508   fi
509 }
510 
511 ## display processes tree in less
512 pst ()
513 { pstree -p $* | less -S }
514 
515 function jaufen() { ssh -X -C -c blowfish obfisticated }
516 function dualg5() { ssh -X -C -c blowfish obfisticated }
517 function agnel() { ssh -X -C -c blowfish obfisticated }
518 function manjula() { ssh -X -Y -C -c blowfish obfisticated }
519 function wendell() { ssh -X -Y -C -c blowfish obfisticated }
520 function orkan() { ssh -X -C -c blowfish obfisticated }
521 function taifun() { ssh -X -C -c blowfish obfisticated }
522 function hurrikan() { ssh -X -C -c blowfish obfisticated }
523 function hobbes() { ssh -X -C -c blowfish obfisticated }
524 function susi() { ssh -X -C -c blowfish obfisticated }
525 function blop() { ssh -X -C -c blowfish obfisticated }
526 function laway() { echo status away > ~jdq/.licq/licq_fifo }
527 function loffline() { echo status offline > ~jdq/.licq/licq_fifo }
528 function lonline() { echo status online > ~jdq/.licq/licq_fifo }
529 function twineterm {
530     X -screen ScreenTwinView :1 -ac & x2pid=$!
531     sleep 2
532     DISPLAY=:1 Eterm -O
533     kill $x2pid
534 }
535 
536 function newterm {
537     X :1 -ac & x2pid=$!
538     sleep 2
539     DISPLAY=:1 Eterm -O
540     kill $x2pid
541 }
542 
543 function mutt {
544     blub=$LC_CTYPE
545     export LC_CTYPE=en_US.ISO-8859-1
546     export | grep SSH_CLIENT > /dev/null 2&>/dev/null
547     ASK=$?
548     if [[ $ASK -eq 1 ]] && [[ ! $TERM = "linux" ]] then
549         if [[ -f /usr/bin/mutt ]] then
550             /usr/bin/mutt -F ~/.muttrc
551         elif [[ -f /usr/local/bin/mutt ]] then
552             /usr/local/bin/mutt -F ~/.muttrc
553         fi
554     elif [[ $ASK -eq 0 ]] || [[ $TERM = "linux" ]] then
555         if [[ -f /usr/bin/mutt ]] then
556             /usr/bin/mutt -F ~/.muttrc.ssh
557         elif [[ -f /usr/local/bin/mutt ]] then
558             /usr/local/bin/mutt -F ~/.muttrc.ssh
559         fi
560     fi
561     export LC_CTYPE=$blub
562     if [[ $LC_CTYPE = "" ]] then
563         unset LC_CTYPE
564     fi
565 }
566 
567 function mensaplan {
568     mkdir -p /tmp/mensaplan
569     cd /tmp/mensaplan
570     wget http://www.studentenwerk-oldenburg.de/oldenburg/ftp/amuhlhornsweg.html 2> /dev/null
571     wget http://www.studentenwerk-oldenburg.de/oldenburg/ftp/aauhlhornsweg.html 2> /dev/null
572 
573     html2text -style pretty -nobs aauhlhornsweg.html > out.txt
574     html2text -style pretty -nobs amuhlhornsweg.html >> out.txt
575 
576     sed 's/[~@~V~D]/ /' out.txt > out2.txt
577     sed 's/~S/ /' out2.txt > out.txt
578     a2ps -1 --landscape -L 70 -i -B -P display out.txt
579     cd -
580     rm -rf /tmp/mensaplan
581 }
582 
583 function salearn {
584     sa-learn --showdots --ham ~jdq/.mails/fsinfo/cur
585     sa-learn --showdots --ham ~jdq/.mails/inbox/cur
586     sa-learn --showdots --spam ~jdq/.mails/spam/cur
587 }
588 
589 function praesentation {
590     export blub=$LC_ALL
591     export LC_ALL=de_DE
592     startx -- :1 -layout Praesentation & pid=$!
593     xset -dpms
594     xset dpms off
595     xset s off
596     wait $!
597     export LC_ALL=$blub
598     if [[ $LC_ALL = "" ]] then
599         unset LC_ALL
600     fi
601 
602 }
603 
604 zzz () {
605 
606     NAMED_DIRECTORY=$PWD:t; # der Name des jetzigen Verzeichnisses 
607                             # wird an NAMED_DIRECTORY ohne die 
608                             # Hierarchie übergeben. :t steht für tail.
609      # es findet die Setzung eines named directory statt.
610      eval $NAMED_DIRECTORY=$PWD;
611      cd ~$NAMED_DIRECTORY;
612      # es wird in das named directory gesprungen.
613      # ist mit dem bestehenden Verzeichnis identisch aber der Name ist
614      # kürzer im Prompt.
615 }
616 
617 function kernel() {
618     printf 'GET /kdist/finger_banner HTTP1.0\n\n' | nc www.kernel.org 80 | grep latest
619 }
620 
621 function http_header() {
622        # This is zsh but still no gnu echoism ;P
623        if [[ $2 != "" ]] { port=$2 } else { port=80 }
624        if [[ $3 != "" ]] { vhost="$3" } else { vhost=$1 }
625 
626        printf "HEAD /$4 HTTP/1.1\\nHost: $vhost\nConnection: close\n\n" \
627         | nc $1 $port
628 }
629 
630 function 2html() { vim -n -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 > /dev/null 2> /dev/null }
631 
632 function emacs() {
633     files="$@"
634     files=${files:-/dev/zero}
635 
636     if [ -z $DISPLAY ]; then
637       emacsclient -a vim "$files"
638     else
639       emacsclient -a emacs "$files"
640     fi
641 }
642 
643 function chat {
644     if [[ "calvin" == "`hostname`" ]]; then
645         if [[ `ps ux | grep centericq | wc -l` -eq 1 ]]; then
646             x=$LC_ALL
647             export LC_ALL=de_DE
648             screen -d -m centericq
649             export LC_ALL=$x
650             if [ $LC_ALL = "" ]; then
651                 unset LC_ALL
652             fi
653             sleep 2
654         fi
655         screen -xRR
656     else
657         ssh -t obfisticated chat
658     fi
659 }
660 
661 function d {
662     if [[ -f ~/.zsh/dirs ]] then
663         dirstack=( ${(uf)"$(< ~/.zsh/dirs)"} )
664     fi
665     if [ $dirstack[0] = `pwd` ]; then
666         dirstack[0]=()
667     fi
668     dirs -v
669 }
670 
671 function cprompt {
672 red='%{^[[01;31m%}'
673 white_on_blue='%{^[[0;37;44m%}'
674 green='%{^[[01;32m%}'
675 yellow='%{^[[01;33m%}'
676 blue='%{^[[01;34m%}'
677 magenta='%{^[[01;35m%}'
678 cyan='%{^[[01;36m%}'
679 nocolor='%{^[[0m%}'
680 if [[ $1 == "nocolor"  ]]; then
681 PROMPT='
682 >-(%n@%M)-(%T)-(%l)->
683 >-< '
684 RPROMPT='>-(%~/)'
685 elif [ $UID -eq 0 ]; then
686 PROMPT="
687 ${red}>-(${yellow}%n${red}@${yellow}%m${red})-(${yellow}%T${red})-(${yellow}%y${red})->${nocolor}
688 ${red}>-< ${nocolor}"
689 RPROMPT="${nocolor}${red}>-(${yellow}%~/${red})${nocolor}"
690 else
691 PROMPT="
692 ${blue}>-(${yellow}%n${blue}@${yellow}%m${blue})-(${yellow}%(0T.0.)%(1T.0.)%(2T.0.)%(3T.0.)%(4T.0.)%(5T.0.)%(6T.0.)%(7T.0.)%(8T.0.)%(9T.0.)%T${blue})-(${yellow}%y${blue})->${nocolor}
693 ${blue}>-< ${nocolor}"
694 RPROMPT="${blue}>-(${yellow}%~/${blue})${nocolor}"
695 fi
696 }
697 
698 cprompt
699 
700 function svnu {
701 exec svn update "$@" 2>&1 \
702 | awk '/^C | conflicts /                  { print "\033[1;31m" $0"\033[0m"; next }
703 /svn update/                       { print "\033[0;32m" $0"\033[0m"; next }
704 /^\? /                             { print "\033[0;33m" $0"\033[0m"; next }
705 /^A /                              { print "\033[1;33m" $0"\033[0m"; next }
706 /^N /                              { print "\033[1;33m" $0"\033[0m"; next } # import
707 /^R /                              { print "\033[0;35m" $0"\033[0m"; next }
708 /^P /                              { print "\033[0;36m" $0"\033[0m"; next }
709 /^Merging differences /            { print "\033[0;36m" $0"\033[0m"; next }
710 /already contains the differences/ { print "\033[0;36m" $0"\033[0m"; next }
711 /^U /                              { print "\033[1;32m" $0"\033[0m"; next }
712 /^M /                              { print "\033[0;34m" $0"\033[0m"; next }
713 /^(RCS file: |retrieving |done$)/  { print "\033[1;32m" $0"\033[0m"; next }
714 /not .* pertinent/                 { print "\033[0;1m"  $0"\033[0m"; next }
715 
716 # Nothing should reach here
717 { print "\033[1;35m" $0 }
718 
719 END { printf "\033[0m" }'
720 }
721 
722 function svna {
723 exec svn add "$@" 2>&1 \
724 | awk '/^C | conflicts /                  { print "\033[1;31m" $0"\033[0m"; next }
725 /svn update/                       { print "\033[0;32m" $0"\033[0m"; next }
726 /^\? /                             { print "\033[0;33m" $0"\033[0m"; next }
727 /^A /                              { print "\033[1;33m" $0"\033[0m"; next }
728 /^N /                              { print "\033[1;33m" $0"\033[0m"; next } # import
729 /^R /                              { print "\033[0;35m" $0"\033[0m"; next }
730 /^P /                              { print "\033[0;36m" $0"\033[0m"; next }
731 /^Merging differences /            { print "\033[0;36m" $0"\033[0m"; next }
732 /already contains the differences/ { print "\033[0;36m" $0"\033[0m"; next }
733 /^U /                              { print "\033[1;32m" $0"\033[0m"; next }
734 /^M /                              { print "\033[0;34m" $0"\033[0m"; next }
735 /^(RCS file: |retrieving |done$)/  { print "\033[1;32m" $0"\033[0m"; next }
736 /not .* pertinent/                 { print "\033[0;1m"  $0"\033[0m"; next }
737 
738 # Nothing should reach here
739 { print "\033[1;35m" $0 }
740 
741 END { printf "\033[0m" }'
742 }
743 
744 function svnl {
745     svn log $*
746 }
747 
748 # insert host specific stuff
749 if [ -f .zshrc.`hostname` ]; then
750     source .zshrc.`hostname`
751 elif [ -f .zshrc.arbi ]; then
752     source .zshrc.arbi
753 elif [ -f .zshrc.local ]; then
754     source .zshrc.local
755 fi