same as the last commit, just for skel/.zshrc this time.
[grml-etc-core.git] / etc / skel / .zshrc
1 # Filename:      .zshrc
2 # Purpose:       config file for zsh
3 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
4 # Bug-Reports:   see http://grml.org/bugs/
5 # License:       This file is licensed under the GPL v2.
6 # Latest change: Don Mai 31 17:19:00 CEST 2007 [mika]
7 ################################################################################
8
9 # source ~/.zshrc.global {{{
10 # see /etc/zsh/zshrc for some general settings
11 # If you don't have write permissions to /etc/zsh/zshrc on your own
12 # copy the file to your $HOME as /.zshrc.global and we source it:
13   if [ -r ~/.zshrc.global ] ; then
14      . ~/.zshrc.global
15   fi
16 # }}}
17
18 # check whether global file has been read {{{
19   if [ -z "$ZSHRC_GLOBAL_HAS_BEEN_READ" ] ; then
20      print 'Warning: global zsh config has not been read'>&2
21   fi
22 # }}}
23
24 # autoloading stuff {{{
25 # associate types and extensions (be aware with perl scripts and anwanted behaviour!)
26 #  type zsh-mime-setup &>/dev/null || { autoload zsh-mime-setup && zsh-mime-setup }
27 #  alias -s pl='perl -S'
28 # }}}
29
30 # completion system {{{
31 # just make sure it is loaded in this file too
32   type compinit &>/dev/null || { autoload -U compinit && compinit }
33 # }}}
34
35 # make sure isgrmlsmall is defined {{{
36   type isgrmlsmall &>/dev/null || function isgrmlsmall () { return 1 }
37 # }}}
38
39 ## variables {{{
40
41 # do you want grmlsmall-specific adjustments?
42   GRMLSMALL_SPECIFIC=1
43
44 # set terminal property (used e.g. by msgid-chooser)
45   export COLORTERM="yes"
46
47 # set default browser
48   if [ -z "$BROWSER" ] ; then
49      if [ -n "$DISPLAY" ] ; then
50         #v# If X11 is running
51         [ -x $(which firefox) ] && export BROWSER=firefox
52      else
53         #v# If no X11 is running
54         [ -x $(which w3m) ] && export BROWSER=w3m
55      fi
56   fi
57   #v#
58   (( ${+PAGER} ))   || export PAGER="less"
59
60 # export qtdir
61   #m# v QTDIR \kbd{/usr/share/qt[34]}\quad [for non-root only]
62   [ -d /usr/share/qt3 ] && export QTDIR=/usr/share/qt3
63   [ -d /usr/share/qt4 ] && export QTDIR=/usr/share/qt4
64
65 # support running 'jikes *.java && jamvm HelloWorld' OOTB:
66   #v# [for non-root only]
67   [ -f /usr/share/classpath/glibj.zip ] && export JIKESPATH=/usr/share/classpath/glibj.zip
68 # }}}
69
70 ## set options {{{
71
72 # Allow comments even in interactive shells i. e.
73 # $ uname # This command prints system informations
74 # zsh: bad pattern: #
75 # $ setopt interactivecomments
76 # $ uname # This command prints system informations
77 # Linux
78 #  setopt interactivecomments
79
80 # ctrl-s will no longer freeze the terminal.
81 #  stty erase "^?"
82
83 # }}}
84
85 # {{{ global aliases
86 # These do not have to be at the beginning of the command line.
87 # Avoid typing cd ../../ for going two dirs down and so on
88 # Usage, e.g.: "$ cd ...' or just '$ ...' with 'setopt auto_cd'
89 # Notice: deactivated by 061112 by default, we use another approach
90 # known as "power completion / abbreviation expansion"
91 #  alias -g '...'='../..'
92 #  alias -g '....'='../../..'
93 #  alias -g BG='& exit'
94 #  alias -g C='|wc -l'
95 #  alias -g G='|grep'
96 #  alias -g H='|head'
97 #  alias -g Hl=' --help |& less -r'
98 #  alias -g K='|keep'
99 #  alias -g L='|less'
100 #  alias -g LL='|& less -r'
101 #  alias -g M='|most'
102 #  alias -g N='&>/dev/null'
103 #  alias -g R='| tr A-z N-za-m'
104 #  alias -g SL='| sort | less'
105 #  alias -g S='| sort'
106 #  alias -g T='|tail'
107 #  alias -g V='| vim -'
108 # }}}
109
110 ## aliases {{{
111
112 # Xterm resizing-fu.
113 # Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
114   alias hide='echo -en "\033]50;nil2\007"'
115   alias tiny='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-80-*-*-c-*-iso8859-15\007"'
116   alias small='echo -en "\033]50;6x10\007"'
117   alias medium='echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-15\007"'
118   alias default='echo -e "\033]50;-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-15\007"'
119   alias large='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-150-*-*-c-*-iso8859-15\007"'
120   alias huge='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-210-*-*-c-*-iso8859-15\007"'
121   alias smartfont='echo -en "\033]50;-artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*\007"'
122   alias semifont='echo -en "\033]50;-misc-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-15\007"'
123 #  if [ "$TERM" = "xterm" ] && [ "$LINES" -ge 50 ] && [ "$COLUMNS" -ge 100 ] && [ -z "$SSH_CONNECTION" ]; then
124 #          large
125 #  fi
126
127 # general
128   #a2# Execute \kbd{du -sch}
129   alias da='du -sch'
130   #a2# Execute \kbd{jobs -l}
131   alias j='jobs -l'
132 #  alias u='translate -i'          # translate
133
134 # compile stuff
135   #a2# Execute \kbd{./configure}
136   alias CO="./configure"
137   #a2# Execute \kbd{./configure --help}
138   alias CH="./configure --help"
139
140 # http://conkeror.mozdev.org/
141   #a2# Run a keyboard driven firefox
142   alias conkeror='firefox -chrome chrome://conkeror/content'
143
144 # arch/tla stuff
145   if type -p tla &>/dev/null ; then
146      #a2# Execute \kbd{tla what-changed --diffs | less}
147      alias tdi='tla what-changed --diffs | less'
148      #a2# Execute \kbd{tla-buildpackage}
149      alias tbp='tla-buildpackage'
150      #a2# Execute \kbd{tla archive-mirror}
151      alias tmi='tla archive-mirror'
152      #a2# Execute \kbd{tla commit}
153      alias tco='tla commit'
154      #a2# Execute \kbd{tla star-merge}
155      alias tme='tla star-merge'
156   fi
157
158 # listing stuff
159   #a2# Execute \kbd{ls -lSrah}
160   alias dir="ls -lSrah"
161   #a2# Only show dot-directories
162   alias lad='ls -d .*(/)'                # only show dot-directories
163   #a2# Only show dot-files
164   alias lsa='ls -a .*(.)'                # only show dot-files
165   #a2# Only files with setgid/setuid/sticky flag
166   alias lss='ls -l *(s,S,t)'             # only files with setgid/setuid/sticky flag
167   #a2# Only show 1st ten symlinks
168   alias lsl='ls -l *(@[1,10])'           # only symlinks
169   #a2# Display only executables
170   alias lsx='ls -l *(*[1,10])'           # only executables
171   #a2# Display world-{readable,writable,executable} files
172   alias lsw='ls -ld *(R,W,X.^ND/)'       # world-{readable,writable,executable} files
173   #a2# Display the ten biggest files
174   alias lsbig="ls -flh *(.OL[1,10])"     # display the biggest files
175   #a2# Only show directories
176   alias lsd='ls -d *(/)'                 # only show directories
177   #a2# Only show empty directories
178   alias lse='ls -d *(/^F)'               # only show empty directories
179   #a2# Display the ten newest files
180   alias lsnew="ls -rl *(D.om[1,10])"     # display the newest files
181   #a2# Display the ten oldest files
182   alias lsold="ls -rtlh *(D.om[1,10])"   # display the oldest files
183   #a2# Display the ten smallest files
184   alias lssmall="ls -Srl *(.oL[1,10])"   # display the smallest files
185
186 # chmod
187   #a2# Execute \kbd{chmod 600}
188   alias rw-='chmod 600'
189   #a2# Execute \kbd{chmod 700}
190   alias rwx='chmod 700'
191   #m# a2 r-{}- Execute \kbd{chmod 644}
192   alias r--='chmod 644'
193   #a2# Execute \kbd{chmod 755}
194   alias r-x='chmod 755'
195
196 # some useful aliases
197   #a2# Execute \kbd{mkdir -o}
198   alias md='mkdir -p'
199
200   [ -x $(which ipython) ] && alias ips='ipython -p sh'
201
202 # console stuff
203   #a2# Execute \kbd{mplayer -vo fbdev}
204   alias cmplayer='mplayer -vo fbdev'
205   #a2# Execute \kbd{mplayer -vo fbdev -fs -zoom}
206   alias fbmplayer='mplayer -vo fbdev -fs -zoom'
207   #a2# Execute \kbd{links2 -driver fb}
208   alias fblinks='links2 -driver fb'
209
210 # ignore ~/.ssh/known_hosts entries
211 #  alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
212   #a2# ssh with StrictHostKeyChecking=no \\&\quad and UserKnownHostsFile unset
213   alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
214   alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
215
216 # use colors when browsing man pages (if not using pinfo or PAGER=most)
217   [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
218
219 # check whether Debian's package management (dpkg) is running
220   #a2# Check whether a dpkg instance is currently running
221   type salias &>/dev/null && salias check_dpkg_running="dpkg_running"
222
223 # work around non utf8 capable software in utf environment
224   if type isutfenv &>/dev/null ; then
225      if [ -x $(which mrxvt) ] ; then
226         isutfenv && [ -n "$LANG" ] && alias mrxvt="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} mrxvt"
227      fi
228    
229      if [ -x $(which aterm) ] ; then
230         isutfenv && [ -n "$LANG" ] && alias aterm="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} aterm"
231      fi
232    
233      if [ -x $(which centericq) ] ; then
234         isutfenv && [ -n "$LANG" ] && alias centericq="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} centericq"
235      fi
236   fi
237 # }}}
238
239 ## useful functions {{{
240
241 # searching
242   #f4# Search for newspostings from authors
243   agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
244   #f4# Search Debian Bug Tracking System by BugID in mbox format
245   debbug()  { ${=BROWSER} "http://bugs.debian.org/$*" }
246   #f4# Search Debian Bug Tracking System
247   debbugm() { bts show --mbox $1 } # provide bugnummer as "$1"
248   #f4# Search DMOZ
249   dmoz()    { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
250   #f4# Search German   Wiktionary
251   dwicti()  { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }
252   #f4# Search English  Wiktionary
253   ewicti()  { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }
254   #f4# Search Google Groups
255   ggogle()  { ${=BROWSER} "http://groups.google.com/groups?q=$*" }
256   #f4# Search Google
257   google()  { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }
258   #f4# Search Google Groups for MsgID
259   mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }
260   #f4# Search Netcraft
261   netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }
262   #f4# Use German Wikipedia's full text search
263   swiki()   { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }
264   #f4# search \kbd{dict.leo.org}
265   oleo()    { ${=BROWSER} "http://dict.leo.org/?search=$*" }
266   #f4# Search German   Wikipedia
267   wikide () { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }
268   #f4# Search English  Wikipedia
269   wikien()  { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
270   #f4# Search official debs
271   wodeb ()  { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
272   #m# f4 gex() Exact search via Google
273   which google &>/dev/null && gex () { google "\"[ $1]\" $*" } # exact search at google
274
275 # misc
276   #f5# Backup \kbd{file {\rm to} file\_timestamp}
277   bk()      { cp -b ${1} ${1}_`date --iso-8601=m` }
278   #f5# Copied diff
279   cdiff()   { diff -crd "$*" | egrep -v "^Only in |^Binary files " }
280   #f5# cd to directoy and list files
281   cl()      { cd $1 && ls -a }        # cd && ls
282   #f5# Cvs add
283   cvsa()    { cvs add $* && cvs com -m 'initial checkin' $* }
284   #f5# Cvs diff
285   cvsd()    { cvs diff -N $* |& $PAGER }
286   #f5# Cvs log
287   cvsl()    { cvs log $* |& $PAGER }
288   #f5# Cvs update
289   cvsq()    { cvs -nq update }
290   #f5# Rcs2log
291   cvsr()    { rcs2log $* | $PAGER }
292   #f5# Cvs status
293   cvss()    { cvs status -v $* }
294   #f5# Disassemble source files using gcc and as
295   disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null }
296   #f5# Firefox remote control - open given URL
297   fir()     { firefox -a firefox -remote "openURL($1)" }
298   #f5# Create Directoy and \kbd{cd} to it
299   mcd()     { mkdir -p "$@"; cd "$@" } # mkdir && cd
300   #f5# Unified diff to timestamped outputfile
301   mdiff()   { diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1" }
302   #f5# Memory overview
303   memusage(){ ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc }
304   #f5# Show contents of tar file
305   shtar()   { gunzip -c $1 | tar -tf - -- | $PAGER }
306   #f5# Show contents of tgz file
307   shtgz()   { tar -ztf $1 | $PAGER }
308   #f5# Show contents of zip file
309   shzip()   { unzip -l $1 | $PAGER }
310   #f5# Greps signature from file
311   sig()     { agrep -d '^-- $' "$*" ~/.Signature }
312   #f5# Unified diff
313   udiff()   { diff -urd $* | egrep -v "^Only in |^Binary files " }
314   #f5# (Mis)use \kbd{vim} as \kbd{less}
315   viless()  { vim --cmd 'let no_plugin_maps = 1' -c "so \$VIMRUNTIME/macros/less.vim" "${@:--}" }
316
317   # download video from youtube
318   ytdl() {
319     if ! [ -n "$2" ] ; then
320        print "Usage: ydtl http://youtube.com/watch?v=.... outputfile.flv">&2
321        return 1
322     else
323        wget -O${2} "http://youtube.com/get_video?"${${${"$(wget -o/dev/null -O- "${1}" | grep -e watch_fullscreen)"}##*watch_fullscreen\?}%%\&fs=*}
324     fi
325   }
326
327
328 # Function Usage: doc packagename
329   #f5# \kbd{cd} to /usr/share/doc/\textit{package}
330   doc() { cd /usr/share/doc/$1 && ls }
331   _doc() { _files -W /usr/share/doc -/ }
332   type compdef &>/dev/null && compdef _doc doc
333
334 #f5# Make screenshot
335   sshot() {
336         [[ ! -d ~/shots  ]] && mkdir ~/shots
337         #cd ~/shots ; sleep 5 ; import -window root -depth 8 -quality 80 `date "+%Y-%m-%d--%H:%M:%S"`.png
338         cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg
339   }
340
341 # list images only
342   limg() {
343     local -a images
344     images=( *.{jpg,gif,png}(.N) )
345     if [[ $#images -eq 0 ]] ; then
346       print "No image files found"
347     else
348       ls "$@" "$images[@]"
349     fi
350   }
351
352 #f5# Create PDF file from source code
353   makereadable() {
354      output=$1
355      shift
356      a2ps --medium A4dj -E -o $output $*
357      ps2pdf $output
358   }
359
360 # zsh with perl-regex - use it e.g. via:
361 # regcheck '\s\d\.\d{3}\.\d{3} Euro' ' 1.000.000 Euro'
362 #f5# Checks whether a regex matches or not.\\&\quad Example: \kbd{regcheck '.\{3\} EUR' '500 EUR'}
363   regcheck() {
364     zmodload -i zsh/pcre
365     pcre_compile $1 && \
366     pcre_match $2 && echo "regex matches" || echo "regex does not match"
367   }
368
369 #f5# List files which have been modified within the last {\it n} days
370   new() { print -l *(m-$1) }
371
372 #f5# Grep in history
373   greph () { history 0 | grep $1 }
374   # use colors when GNU grep with color-support
375   #a2# Execute \kbd{grep -{}-color=auto}
376   (grep --help 2>/dev/null |grep -- --color) >/dev/null && alias grep='grep --color=auto'
377   #a2# Execute \kbd{grep -i -{}-color=auto}
378   alias GREP='grep -i --color=auto'
379
380 # one blank line between each line
381   if [ -r ~/.terminfo/m/mostlike ] ; then
382 #     alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
383      #f5# Watch manpages in a stretched style
384      man2() { PAGER='dash -c "sed G | /usr/bin/less"' TERM=mostlike /usr/bin/man "$@" ; }
385   fi
386
387 # jump between directories
388 # Copyright 2005 Nikolai Weibull <nikolai@bitwi.se>
389 # notice: option AUTO_PUSHD has to be set
390   #f5# Jump between directories
391   d(){
392     emulate -L zsh
393     autoload -U colors
394     local color=$fg_bold[blue]
395     integer i=0
396     dirs -p | while read dir; do
397       local num="${$(printf "%-4d " $i)/ /.}"
398       printf " %s  $color%s$reset_color\n" $num $dir
399       (( i++ ))
400     done
401     integer dir=-1
402     read -r 'dir?Jump to directory: ' || return
403     (( dir == -1 )) && return
404     if (( dir < 0 || dir >= i )); then
405       echo d: no such directory stack entry: $dir
406       return 1
407     fi
408     cd ~$dir
409   }
410
411 # usage example: 'lcheck strcpy'
412 #f5# Find out which libs define a symbol
413   lcheck() {
414      if [ -n "$1" ] ; then
415         nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
416       else
417         echo "Usage: lcheck <function>" >&2
418      fi
419   }
420
421 #f5# Clean up directory - remove well known tempfiles
422   purge() {
423         FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
424         NBFILES=${#FILES}
425         if [[ $NBFILES > 0 ]]; then
426                 print $FILES
427                 local ans
428                 echo -n "Remove these files? [y/n] "
429                 read -q ans
430                 if [[ $ans == "y" ]]
431                 then
432                         rm ${FILES}
433                         echo ">> $PWD purged, $NBFILES files removed"
434                 else
435                         echo "Ok. .. than not.."
436                 fi
437         fi
438    }
439
440 # Translate DE<=>EN
441 # 'translate' looks up fot a word in a file with language-to-language
442 # translations (field separator should be " : "). A typical wordlist looks
443 # like at follows:
444 #  | english-word : german-transmission
445 # It's also only possible to translate english to german but not reciprocal.
446 # Use the following oneliner to turn back the sort order:
447 #  $ awk -F ':' '{ print $2" : "$1" "$3 }' \
448 #    /usr/local/lib/words/en-de.ISO-8859-1.vok > ~/.translate/de-en.ISO-8859-1.vok
449 #f5# Translates a word
450   trans() {
451         case "$1" in
452                 -[dD]*) translate -l de-en $2
453                 ;;
454                 -[eE]*) translate -l en-de $2
455                 ;;
456                 *)
457                 echo "Usage: $0 { -D | -E }"
458                 echo "         -D == German to English"
459                 echo "         -E == English to German"
460         esac
461   }
462
463 # Some quick Perl-hacks aka /useful/ oneliner
464 #  bew() { perl -le 'print unpack "B*","'$1'"' }
465 #  web() { perl -le 'print pack "B*","'$1'"' }
466 #  hew() { perl -le 'print unpack "H*","'$1'"' }
467 #  weh() { perl -le 'print pack "H*","'$1'"' }
468 #  pversion()    { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
469 #  getlinks ()   { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
470 #  gethrefs ()   { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
471 #  getanames ()  { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
472 #  getforms ()   { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
473 #  getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
474 #  getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
475 #  showINC ()    { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
476 #  vimpm ()      { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
477 #  vimhelp ()    { vim -c "help $1" -c on -c "au! VimEnter *" }
478
479 #f5# List all occurrences of programm in current PATH
480   plap() {
481         if [[ $# = 0 ]]
482         then
483                 echo "Usage:    $0 program"
484                 echo "Example:  $0 zsh"
485                 echo "Lists all occurrences of program in the current PATH."
486         else
487                 ls -l ${^path}/*$1*(*N)
488         fi
489   }
490
491 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
492 #f5# Select items for specific command(s) from history
493   selhist() {
494         emulate -L zsh
495         local TAB=$'\t';
496         (( $# < 1 )) && {
497                 echo "Usage: $0 command"
498                 return 1
499         };
500         cmd=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
501         print -l $cmd | less -F
502         echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
503         local answer
504         read answer
505         print -z "${cmd[$answer]#*$TAB}"
506   }
507
508 # Use vim to convert plaintext to HTML
509   #f5# Transform files to html with highlighting
510   2html() { vim -u NONE -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 &>/dev/null }
511
512 # Usage: simple-extract <file>
513 #f5# Smart archive extractor
514   simple-extract () {
515         if [[ -f $1 ]]
516         then
517                 case $1 in
518                         *.tar.bz2)  bzip2 -v -d $1      ;;
519                         *.tar.gz)   tar -xvzf $1        ;;
520                         *.rar)      unrar $1            ;;
521                         *.deb)      ar -x $1            ;;
522                         *.bz2)      bzip2 -d $1         ;;
523                         *.lzh)      lha x $1            ;;
524                         *.gz)       gunzip -d $1        ;;
525                         *.tar)      tar -xvf $1         ;;
526                         *.tgz)      gunzip -d $1        ;;
527                         *.tbz2)     tar -jxvf $1        ;;
528                         *.zip)      unzip $1            ;;
529                         *.Z)        uncompress $1       ;;
530                         *)          echo "'$1' Error. Please go away" ;;
531                 esac
532         else
533                 echo "'$1' is not a valid file"
534         fi
535   }
536
537 # Usage: smartcompress <file> (<type>)
538 #f5# Smart archive creator
539   smartcompress() {
540         if [ $2 ]; then
541                 case $2 in
542                         tgz | tar.gz)   tar -zcvf$1.$2 $1 ;;
543                         tbz2 | tar.bz2) tar -jcvf$1.$2 $1 ;;
544                         tar.Z)          tar -Zcvf$1.$2 $1 ;;
545                         tar)            tar -cvf$1.$2  $1 ;;
546                         gz | gzip)      gzip           $1 ;;
547                         bz2 | bzip2)    bzip2          $1 ;;
548                         *)
549                         echo "Error: $2 is not a valid compression type"
550                         ;;
551                 esac
552         else
553                 smartcompress $1 tar.gz
554         fi
555   }
556
557 # Usage: show-archive <archive>
558 #f5# List an archive's content
559   show-archive() {
560         if [[ -f $1 ]]
561         then
562                 case $1 in
563                         *.tar.gz)      gunzip -c $1 | tar -tf - -- ;;
564                         *.tar)         tar -tf $1 ;;
565                         *.tgz)         tar -ztf $1 ;;
566                         *.zip)         unzip -l $1 ;;
567                         *.bz2)         bzless $1 ;;
568                         *)             echo "'$1' Error. Please go away" ;;
569                 esac
570         else
571                 echo "'$1' is not a valid archive"
572         fi
573   }
574
575 #f5# Follow symlinks
576   folsym() {
577     if [[ -e $1 || -h $1 ]]; then
578         file=$1
579     else
580         file=`which $1`
581     fi
582     if [[ -e $file || -L $file ]]; then
583         if [[ -L $file ]]; then
584             echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
585             folsym `perl -le '$file = $ARGV[0];
586                               $dest = readlink $file;
587                               if ($dest !~ m{^/}) {
588                                   $file =~ s{(/?)[^/]*$}{$1$dest};
589                               } else {
590                                   $file = $dest;
591                               }
592                               $file =~ s{/{2,}}{/}g;
593                               while ($file =~ s{[^/]+/\.\./}{}) {
594                                   ;
595                               }
596                               $file =~ s{^(/\.\.)+}{};
597                               print $file' $file`
598         else
599             ls -d $file
600         fi
601     else
602         echo $file
603     fi
604   }
605
606 # It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
607 #f5# Use \kbd{vim} as your manpage reader
608   vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
609
610 # function readme() { $PAGER -- (#ia3)readme* }
611 #f5# View all README-like files in current directory in pager
612   readme() {
613         local files
614         files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
615         if (($#files))
616         then $PAGER $files
617         else
618                 print 'No README files.'
619         fi
620   }
621
622 # suidfind() { ls -latg $path | grep '^...s' }
623 #f5# Find all files in \$PATH with setuid bit set
624   suidfind() { ls -latg $path/*(sN) }
625
626 # See above but this is /better/ ... anywise ..
627   findsuid() {
628     print 'Output will be written to ~/suid_* ...'
629     $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
630     $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
631     $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
632     $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
633     print 'Finished'
634   }
635
636 #f5# Reload given functions
637   refunc() {
638         for func in $argv
639         do
640                 unfunction $func
641                 autoload $func
642         done
643   }
644
645 # a small check to see which DIR is located on which server/partition.
646 # stolen and modified from Sven's zshrc.forall
647   #f5# Report diskusage of a directory
648   dirspace() {
649     if [ -n "$1" ] ; then
650        for dir in $* ; do
651           if [ -d "$dir" ] ; then
652              ( cd $dir; echo "-<$dir>"; du -shx .; echo);
653           else
654              echo "warning: $dir does not exist" >&2
655           fi
656        done
657     else
658         for dir in $path; do
659           if [ -d "$dir" ] ; then
660              ( cd $dir; echo "-<$dir>"; du -shx .; echo);
661           else
662              echo "warning: $dir does not exist" >&2
663           fi
664         done
665     fi
666   }
667
668 # % slow_print `cat /etc/passwd`
669 #f5# Slowly print out parameters
670   slow_print() {
671         for argument in "${@}"
672         do
673                 for ((i = 1; i <= ${#1} ;i++)) {
674                         print -n "${argument[i]}"
675                         sleep 0.08
676                 }
677                 print -n " "
678         done
679         print ""
680   }
681
682 #f5# Show some status info
683   status() {
684         print ""
685         print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
686         print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
687         print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
688         print "Login.: $LOGNAME (UID = $EUID) on $HOST"
689         print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
690         print "Uptime:$(uptime)"
691         print ""
692   }
693
694 # Rip an audio CD
695   #f5# Rip an audio CD
696   audiorip() {
697         mkdir -p ~/ripps
698         cd ~/ripps
699         cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
700         cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
701         echo " * Would you like to burn the cd now? (yes/no)"
702         read input
703         if
704                 [ "$input" = "yes" ]; then
705                 echo " ! Burning Audio CD"
706                 audioburn
707                 echo " * done."
708         else
709                 echo " ! Invalid response."
710         fi
711   }
712
713 # and burn it
714   #f5# Burn an audio CD (in combination with audiorip)
715   audioburn() {
716         cd ~/ripps
717         cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
718         echo " * Should I remove the temporary files? (yes/no)"
719         read input
720         if [ "$input" = "yes" ]; then
721                 echo " ! Removing Temporary Files."
722                 cd ~
723                 rm -rf ~/ripps
724                 echo " * done."
725         else
726                 echo " ! Invalid response."
727         fi
728   }
729
730 #f5# Make an audio CD from all mp3 files
731   mkaudiocd() {
732         cd ~/ripps
733         for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
734         for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
735         for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
736         normalize -m *.wav
737         for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
738   }
739
740 #f5# Create an ISO image. You are prompted for\\&\quad volume name, filename and directory
741   mkiso() {
742         echo " * Volume name "
743         read volume
744         echo " * ISO Name (ie. tmp.iso)"
745         read iso
746         echo " * Directory or File"
747         read files
748         mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
749   }
750
751 #f5# Simple thumbnails generator
752   genthumbs () {
753     rm -rf thumb-* index.html
754     echo "
755 <html>
756   <head>
757     <title>Images</title>
758   </head>
759   <body>" > index.html
760     for f in *.(gif|jpeg|jpg|png)
761     do
762         convert -size 100x200 "$f" -resize 100x200 thumb-"$f"
763         echo "    <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
764     done
765     echo "
766   </body>
767 </html>" >> index.html
768   }
769
770 #f5# Set all ulimit parameters to \kbd{unlimited}
771   allulimit() {
772     ulimit -c unlimited
773     ulimit -d unlimited
774     ulimit -f unlimited
775     ulimit -l unlimited
776     ulimit -n unlimited
777     ulimit -s unlimited
778     ulimit -t unlimited
779   }
780
781 # ogg2mp3 with bitrate of 192
782   ogg2mp3_192() {
783     oggdec -o - ${1} | lame -b 192 - ${1:r}.mp3
784   }
785
786 #f5# RFC 2396 URL encoding in Z-Shell
787   urlencode() {
788    setopt localoptions extendedglob
789    input=( ${(s::)1} )
790    print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
791   }
792
793 #f5# Install x-lite (VoIP software)
794   getxlite() {
795     setopt local_options
796     setopt errreturn
797     [ -d ~/tmp ] || mkdir ~/tmp
798     cd ~/tmp
799     echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
800     if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
801        unp X-Lite_Install.tar.gz && echo done || echo failed
802     else
803        echo "Error while downloading." ; return 1
804     fi
805     if [ -x xten-xlite/xtensoftphone ] ; then
806        echo "Execute xten-xlite/xtensoftphone to start xlite."
807     fi
808    }
809
810 #f5# Install skype
811   getskype() {
812     setopt local_options
813     setopt errreturn
814     echo "Downloading debian package of skype."
815     echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
816     wget http://www.skype.com/go/getskype-linux-deb
817     $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
818   }
819
820 #f5# Install beta-version of skype
821   getskypebeta() {
822     setopt local_options
823     setopt errreturn
824     echo "Downloading debian package of skype (beta version)."
825     wget http://www.skype.com/go/getskype-linux-beta-deb
826     $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
827   }
828
829 #f5# Install gizmo (VoIP software)
830   getgizmo() {
831     setopt local_options
832     setopt errreturn
833     echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
834     $SUDO apt-get update
835     $SUDO apt-get install gconf2-common libgconf2-4
836     wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
837     $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
838   }
839
840 #f5# Get and run AIR (Automated Image and Restore)
841   getair() {
842     setopt local_options
843     setopt errreturn
844     [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
845     local VER='1.2.8'
846     wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
847     tar zxf air-$VER.tar.gz
848     cd air-$VER
849     INTERACTIVE=no $SUDO ./install-air-1.2.8
850     [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
851   }
852
853 #f5# Get specific git commitdiff
854   git-get-diff() {
855     if [ -z $GITTREE ] ; then
856       GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
857     fi
858     if ! [ -z $1 ] ; then
859      ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commitdiff;h=$1"
860     else
861       echo "Usage: git-get-diff <commit>"
862     fi
863   }
864
865 #f5# Get specific git commit
866   git-get-commit() {
867     if [ -z $GITTREE ] ; then
868       GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
869     fi
870     if ! [ -z $1 ] ; then
871      ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commit;h=$1"
872     else
873       echo "Usage: git-get-commit <commit>"
874     fi
875   }
876
877 #f5# Get specific git diff
878   git-get-plaindiff() {
879     if [ -z $GITTREE ] ; then
880       GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
881     fi
882     if ! [ -z $1 ] ; then
883       wget "http://kernel.org/git/?p=$GITTREE;a=commitdiff_plain;h=$1" -O $1.diff
884     else
885       echo 'Usage: git-get-plaindiff '
886     fi
887   }
888
889 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
890 #f5# Log 'make install' output
891   mmake() {
892     [[ ! -d ~/.errorlogs ]] && mkdir ~/.errorlogs
893     =make -n install > ~/.errorlogs/${PWD##*/}-makelog
894   }
895
896 #f5# Indent source code
897   smart-indent() {
898     indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs $*
899   }
900
901 # highlight important stuff in diff output, usage example: hg diff | hidiff
902   #m# a2 hidiff \kbd{histring} oneliner for diffs
903   [ -x $(which histring) ] && \
904   alias hidiff="histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'"
905
906 # rename pictures based on information found in exif headers
907   #f5# Rename pictures based on information found in exif headers
908   exirename() {
909     if [ $# -lt 1 ] ; then
910        echo 'Usage: jpgrename $FILES' >& 2
911        return 1
912     else
913        echo -n 'Checking for jhead with version newer than 1.9: '
914        jhead_version=`jhead -h | grep 'used by most Digital Cameras.  v.*' | awk '{print $6}' | tr -d v`
915        if [[ $jhead_version > '1.9' ]]; then
916           echo 'success - now running jhead.'
917           jhead -n%Y-%m-%d_%Hh%M_%f $*
918        else
919           echo 'failed - exiting.'
920        fi
921     fi
922   }
923
924 # open file in vim and jump to line
925 # http://www.downgra.de/archives/2007/05/08/T19_21_11/
926   j2v() {
927     local -a params
928     params=(${*//(#m):[0-9]*:/\\n+${MATCH//:/}}) # replace ':23:' to '\n+23'
929     params=(${(s|\n|)${(j|\n|)params}}) # join array using '\n', then split on all '\n'
930     vim ${params}
931   }
932
933 # get_ic() - queries imap servers for capabilities; real simple. no imaps
934   ic_get() {
935     local port
936     if [[ ! -z $1 ]]; then
937       port=${2:-143}
938       print "querying imap server on $1:${port}...\n";
939       print "a1 capability\na2 logout\n" | nc $1 ${port}
940     else
941       print "usage:\n  $0 <imap-server> [port]"
942     fi
943   }
944
945 # creates a Maildir/ with its {new,cur,tmp} subdirs
946   mkmaildir() {
947     local root subdir
948     root=${MAILDIR_ROOT:-${HOME}/Mail}
949     if [[ -z ${1} ]] ; then print "Usage:\n $0 <dirname>" ; return 1 ; fi
950     subdir=${1}
951     mkdir -p ${root}/${subdir}/{cur,new,tmp}
952   }
953
954 # xtrename() rename xterm from within GNU-screen
955   xtrename() {
956     if [[ -z ${DISPLAY} ]] ; then
957       printf 'xtrename only makes sense in X11.\n'
958       return 1
959     fi
960     if [[ -z ${1} ]] ; then
961       printf 'usage: xtrename() "title for xterm"\n'
962       printf '  renames the title of xterm from _within_ screen.\n'
963       printf '  Also works without screen.\n'
964       return 0
965     fi
966     print -n "\eP\e]0;${1}\C-G\e\\"
967     return 0
968   }
969
970 # hl() highlighted less
971 # http://ft.bewatermyfriend.org/comp/data/zsh/zfunct.html
972   if [ -x $(which highlight) ] ; then
973     function hl() {
974       local theme lang
975       theme=${HL_THEME:-""}
976       case ${1} in
977         (-l|--list)
978           ( printf 'available languages (syntax parameter):\n\n' ;
979             highlight --list-langs ; ) | less -SMr
980           ;;
981         (-t|--themes)
982           ( printf 'available themes (style parameter):\n\n' ;
983             highlight --list-themes ; ) | less -SMr
984           ;;
985         (-h|--help)
986           printf 'usage: hl <syntax[:theme]> <file>\n'
987           printf '    available options: --list (-l), --themes (-t), --help (-h)\n\n'
988           printf '  Example: hl c main.c\n'
989           ;;
990         (*)
991           if [[ -z ${2} ]] || (( ${#argv} > 2 )) ; then
992             printf 'usage: hl <syntax[:theme]> <file>\n'
993             printf '    available options: --list (-l), --themes (-t), --help (-h)\n'
994             (( ${#argv} > 2 )) && printf '  Too many arguments.\n'
995             return 1
996           fi
997           lang=${1%:*}
998           [[ ${1} == *:* ]] && [[ -n ${1#*:} ]] && theme=${1#*:}
999           if [[ -n ${theme} ]] ; then
1000             highlight --xterm256 --syntax ${lang} --style ${theme} ${2} | less -SMr
1001           else
1002             highlight --ansi --syntax ${lang} ${2} | less -SMr
1003           fi
1004           ;;
1005       esac
1006       return 0
1007     }
1008     # ... and a proper completion for hl()
1009     # needs 'highlight' as well, so it fits fine in here.
1010     function _hl_genarg()  {
1011       local expl
1012       if [[ -prefix 1 *: ]] ; then
1013         local themes
1014         themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*})
1015         compset -P 1 '*:'
1016         _wanted -C list themes expl theme compadd ${themes}
1017       else
1018         local langs
1019         langs=(${${${(f)"$(LC_ALL=C highlight --list-langs)"}/ #/}:#*(Installed|Use name)*})
1020         _wanted -C list languages expl languages compadd -S ':' -q ${langs}
1021       fi
1022     }
1023     function _hl_complete() {
1024       _arguments -s '1: :_hl_genarg' '2:files:_path_files'
1025     }
1026     compdef _hl_complete hl
1027   fi
1028
1029 # create small urls via tinyurl.com using wget, grep and sed
1030   zurl() {
1031   [[ -z ${1} ]] && print "please give an url to shrink." && return 1
1032   local url=${1}
1033   local tiny="http://tinyurl.com/create.php?url="
1034   #print "${tiny}${url}" ; return
1035   wget  -O-             \
1036         -o/dev/null     \
1037         "${tiny}${url}" \
1038     | grep -Eio 'value="(http://tinyurl.com/.*)"' \
1039     | sed 's/value=//;s/"//g'
1040 }
1041
1042 # change fluxbox keys from 'Alt-#' to 'Alt-F#' and vice versa
1043   fluxkey-change() {
1044     [ -n "$FLUXKEYS" ] || local FLUXKEYS="$HOME/.fluxbox/keys"
1045     if ! [ -r "$FLUXKEYS" ] ; then
1046        echo "Sorry, \$FLUXKEYS file $FLUXKEYS could not be read - nothing to be done."
1047        return 1
1048     else
1049        if grep -q 'Mod1 F[0-9] :Workspace [0-9]' $FLUXKEYS ; then
1050           echo -n 'Switching to Alt-# mode in ~/.fluxbox/keys: '
1051           sed -i -e 's|^\(Mod[0-9]\+[: space :]\+\)F\([0-9]\+[: space :]\+:Workspace.*\)|\1\2|' $FLUXKEYS && echo done || echo failed
1052        elif grep -q 'Mod1 [0-9] :Workspace [0-9]' $FLUXKEYS ; then
1053           echo -n 'Switching to Alt-F# mode in ~/.fluxbox/keys: '
1054           sed -i -e 's|^\(Mod[0-9]\+[: space :]\+\)\([0-9]\+[: space :]\+:Workspace.*\)|\1F\2|' $FLUXKEYS && echo done || echo failed
1055        else
1056           echo 'Sorry, do not know what to do.'
1057           return 1
1058        fi
1059     fi
1060   }
1061
1062 # }}}
1063
1064 # mercurial related stuff {{{
1065   if type -p hg &>/dev/null ; then
1066   # gnu like diff for mercurial
1067   # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
1068     #f5# GNU like diff for mercurial
1069     hgdi() {
1070       for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
1071     }
1072
1073   # build debian package
1074     #a2# Alias for \kbd{hg-buildpackage}
1075     alias hbp='hg-buildpackage'
1076
1077   # execute commands on the versioned patch-queue from the current repos
1078     alias mq='hg -R $(readlink -f $(hg root)/.hg/patches)'
1079
1080   # diffstat for specific version of a mercurial repository
1081   #   hgstat      => display diffstat between last revision and tip
1082   #   hgstat 1234 => display diffstat between revision 1234 and tip
1083     #f5# Diffstat for specific version of a mercurial repos
1084     hgstat() {
1085       [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
1086     }
1087
1088   # get current mercurial tip via hg itself
1089     #f5# Get current mercurial tip via hg itself
1090     gethgclone() {
1091       setopt local_options
1092       setopt errreturn
1093       if [ -f mercurial-tree/.hg ] ; then
1094         cd mercurial-tree
1095         echo "Running hg pull for retreiving latest version..."
1096         hg pull
1097         echo "Finished update. Building mercurial"
1098         make local
1099         echo "Setting \$PATH to $PWD:\$PATH..."
1100         export PATH="$PWD:$PATH"
1101       else
1102         echo "Downloading mercurial via hg"
1103         hg clone http://selenic.com/repo/hg mercurial-tree
1104         cd mercurial-tree
1105         echo "Building mercurial"
1106         make local
1107         echo "Setting \$PATH to $PWD:\$PATH..."
1108         export PATH="$PWD:$PATH"
1109         echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
1110         # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
1111         # export PYTHONPATH=${HOME}/lib/python
1112       fi
1113     }
1114
1115   fi # end of check whether we have the 'hg'-executable
1116
1117   # get current mercurial snapshot
1118     #f5# Get current mercurial snapshot
1119     gethgsnap() {
1120       setopt local_options
1121       setopt errreturn
1122       if [ -f mercurial-snapshot.tar.gz ] ; then
1123          echo "mercurial-snapshot.tar.gz exists already, skipping download."
1124       else
1125         echo "Downloading mercurial snapshot"
1126         wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
1127       fi
1128       echo "Unpacking mercurial-snapshot.tar.gz"
1129       tar zxf mercurial-snapshot.tar.gz
1130       cd mercurial-snapshot/
1131       echo "Installing required build-dependencies"
1132       $SUDO apt-get update
1133       $SUDO apt-get install python2.4-dev
1134       echo "Building mercurial"
1135       make local
1136       echo "Setting \$PATH to $PWD:\$PATH..."
1137       export PATH="$PWD:$PATH"
1138       echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
1139     }
1140 # }}}
1141
1142 # some useful commands often hard to remember - let's grep for them {{{
1143
1144 # Work around ion/xterm resize bug.
1145 #if [ "$SHLVL" = 1 ]; then
1146 #       if [ -x $(which resize) ]; then
1147 #               eval `resize </dev/null`
1148 #       fi
1149 #fi
1150
1151 # enable jackd:
1152 #  /usr/bin/jackd -dalsa -dhw:0 -r48000 -p1024 -n2
1153 # now play audio file:
1154 #  alsaplayer -o jack foobar.mp3
1155
1156 # send files via netcat
1157 # on sending side:
1158 #  send() {j=$*; tar cpz ${j/%${!#}/}|nc -w 1 ${!#} 51330;}
1159 #  send dir* $HOST
1160 #  alias receive='nc -vlp 51330 | tar xzvp'
1161
1162 # debian stuff:
1163 # dh_make -e foo@localhost -f $1
1164 # dpkg-buildpackage -rfakeroot
1165 # lintian *.deb
1166 # dpkg-scanpackages ./ /dev/null | gzip > Packages.gz
1167 # dpkg-scansources . | gzip > Sources.gz
1168 # grep-dctrl --field Maintainer $* /var/lib/apt/lists/*
1169
1170 # other stuff:
1171 # convert -geometry 200x200 -interlace LINE -verbose
1172 # ldapsearch -x -b "OU=Bedienstete,O=tug" -h ldap.tugraz.at sn=$1
1173 # ps -ao user,pcpu,start,command
1174 # gpg --keyserver blackhole.pca.dfn.de --recv-keys
1175 # xterm -bg black -fg yellow -fn -misc-fixed-medium-r-normal--14-140-75-75-c-90-iso8859-15 -ah
1176 # nc -vz $1 1-1024   # portscan via netcat
1177 # wget --mirror --no-parent --convert-links
1178 # pal -d `date +%d`
1179 # autoload -U tetris; zle -N tetris; bindkey '...' ; echo "press ... for playing tennis"
1180 #
1181 # modify console cursor
1182 # see http://www.tldp.org/HOWTO/Framebuffer-HOWTO-5.html
1183 # print $'\e[?96;0;64c'
1184 # }}}
1185
1186 # finally source a local zshrc and grmlsmall-specific configuration {{{
1187
1188 # The following file is used to remove zsh-config-items that do not work
1189 # in grml-small by default.
1190 # If you do not want these adjustments (for whatever reason),
1191 # there are three ways to accomplish that:
1192 #  a) at the beginning of this file (variables section), set
1193 #     $GRMLSMALL_SPECIFIC to 0 or comment out the variable definition.
1194 #  b) remove/rename .zshrc.grmlsmall
1195 #  c) comment out the following line
1196   (( GRMLSMALL_SPECIFIC > 0 )) && isgrmlsmall && source ~/.zshrc.grmlsmall
1197
1198 # this allows us to stay in sync with /etc/skel/.zshrc
1199 # through 'ln -s /etc/skel/.zshrc ~/.zshrc' and put own
1200 # modifications in ~/.zshrc.local
1201   if [ -r ~/.zshrc.local ] ; then
1202      . ~/.zshrc.local
1203   fi
1204 # }}}
1205
1206 ### doc strings for external functions from files
1207 #m# f5 grml-wallpaper() Sets a wallpaper (try completion for possible values)
1208 ## END OF FILE #################################################################
1209 # vim:foldmethod=marker