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: Sam Mai 12 23:22:28 CEST 2007 [mika]
7 ################################################################################
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
18 # completion system {{{
19 # just make sure it is loaded in this file too
20 type compinit &>/dev/null || { autoload -U compinit && compinit }
23 # make sure isgrmlsmall is defined {{{
24 type isgrmlsmall &>/dev/null || function isgrmlsmall () { return 1 }
29 # do you want grmlsmall-specific adjustments?
32 # set terminal property (used e.g. by msgid-chooser)
33 export COLORTERM="yes"
36 if [ -z "$BROWSER" ] ; then
37 if [ -n "$DISPLAY" ] ; then
38 [ -x $(which firefox) ] && export BROWSER=firefox
40 [ -x $(which w3m) ] && export BROWSER=w3m
43 (( ${+PAGER} )) || export PAGER="less"
46 [ -d /usr/share/qt3 ] && export QTDIR=/usr/share/qt3
47 [ -d /usr/share/qt4 ] && export QTDIR=/usr/share/qt4
49 # support running 'jikes *.java && jamvm HelloWorld' OOTB:
50 [ -f /usr/share/classpath/glibj.zip ] && export JIKESPATH=/usr/share/classpath/glibj.zip
55 # Allow comments even in interactive shells i. e.
56 # $ uname # This command prints system informations
58 # $ setopt interactivecomments
59 # $ uname # This command prints system informations
61 # setopt interactivecomments
63 # ctrl-s will no longer freeze the terminal.
69 # These do not have to be at the beginning of the command line.
70 # Avoid typing cd ../../ for going two dirs down and so on
71 # Usage, e.g.: "$ cd ...' or just '$ ...' with 'setopt auto_cd'
72 # Notice: deactivated by 061112 by default, we use another approach
73 # known as "power completion / abbreviation expansion"
74 # alias -g '...'='../..'
75 # alias -g '....'='../../..'
76 # alias -g BG='& exit'
80 # alias -g Hl=' --help |& less -r'
83 # alias -g LL='|& less -r'
85 # alias -g N='&>/dev/null'
86 # alias -g R='| tr A-z N-za-m'
87 # alias -g SL='| sort | less'
90 # alias -g V='| vim -'
96 # Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
97 alias hide='echo -en "\033]50;nil2\007"'
98 alias tiny='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-80-*-*-c-*-iso8859-15\007"'
99 alias small='echo -en "\033]50;6x10\007"'
100 alias medium='echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-15\007"'
101 alias default='echo -e "\033]50;-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-15\007"'
102 alias large='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-150-*-*-c-*-iso8859-15\007"'
103 alias huge='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-210-*-*-c-*-iso8859-15\007"'
104 alias smartfont='echo -en "\033]50;-artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*\007"'
105 alias semifont='echo -en "\033]50;-misc-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-15\007"'
106 # if [ "$TERM" = "xterm" ] && [ "$LINES" -ge 50 ] && [ "$COLUMNS" -ge 100 ] && [ -z "$SSH_CONNECTION" ]; then
113 # alias u='translate -i' # translate
116 alias CO="./configure"
117 alias CH="./configure --help"
119 # http://conkeror.mozdev.org/
120 alias conkeror='firefox -chrome chrome://conkeror/content'
123 if type -p tla &>/dev/null ; then
124 alias tdi='tla what-changed --diffs | less'
125 alias tbp='tla-buildpackage'
126 alias tmi='tla archive-mirror'
127 alias tco='tla commit'
128 alias tme='tla star-merge'
132 alias dir="ls -lSrah"
133 alias lad='ls -d .*(/)' # only show dot-directories
134 alias lsa='ls -a .*(.)' # only show dot-files
135 alias lss='ls -l *(s,S,t)' # only files with setgid/setuid/sticky flag
136 alias lsl='ls -l *(@[1,10])' # only symlinks
137 alias lsx='ls -l *(*[1,10])' # only executables
138 alias lsw='ls -ld *(R,W,X.^ND/)' # world-{readable,writable,executable} files
139 alias lsbig="ls -flh *(.OL[1,10])" # display the biggest files
140 alias lsd='ls -d *(/)' # only show directories
141 alias lse='ls -d *(/^F)' # only show empty directories
142 alias lsnew="ls -rl *(D.om[1,10])" # display the newest files
143 alias lsold="ls -rtlh *(D.om[1,10])" # display the oldest files
144 alias lssmall="ls -Srl *(.oL[1,10])" # display the smallest files
147 alias rw-='chmod 600'
148 alias rwx='chmod 700'
149 alias r--='chmod 644'
150 alias r-x='chmod 755'
152 # some useful aliases
156 alias cmplayer='mplayer -vo fbdev'
157 alias fbmplayer='mplayer -vo fbdev -fs -zoom'
158 alias fblinks='links2 -driver fb'
160 # ignore ~/.ssh/known_hosts entries
161 # alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
162 alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
163 alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
165 # use colors when browsing man pages (if not using pinfo or PAGER=most)
166 [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
168 # check whether Debian's package management (dpkg) is running
169 salias check_dpkg_running="dpkg_running"
171 # work around non utf8 capable software in utf environment
172 if [ -x /usr/bin/mrxvt ] ; then
173 isutfenv && [ -n "$LANG" ] && alias mrxvt="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} mrxvt"
176 if [ -x /usr/bin/aterm ] ; then
177 isutfenv && [ -n "$LANG" ] && alias aterm="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} aterm"
180 if [ -x /usr/bin/centericq ] ; then
181 isutfenv && [ -n "$LANG" ] && alias centericq="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} centericq"
185 ## useful functions {{{
187 # functions without detailed explanation:
188 agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
189 bk() { cp -b ${1} ${1}_`date --iso-8601=m` }
190 cdiff() { diff -crd "$*" | egrep -v "^Only in |^Binary files " }
191 cl() { cd $1 && ls -a } # cd && ls
192 cvsa() { cvs add $* && cvs com -m 'initial checkin' $* }
193 cvsd() { cvs diff -N $* |& $PAGER }
194 cvsl() { cvs log $* |& $PAGER }
195 cvsq() { cvs -nq update }
196 cvsr() { rcs2log $* | $PAGER }
197 cvss() { cvs status -v $* }
198 debbug() { ${=BROWSER} "http://bugs.debian.org/$*" }
199 debbugm() { bts show --mbox $1 } # provide bugnummer as "$1"
200 disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null }
201 dmoz() { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
202 dwicti() { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }
203 ewicti() { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }
204 fir() { firefox -a firefox -remote "openURL($1)" }
205 ggogle() { ${=BROWSER} "http://groups.google.com/groups?q=$*" }
206 google() { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }
207 mcd() { mkdir -p "$@"; cd "$@" } # mkdir && cd
208 mdiff() { diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1" }
209 memusage(){ ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc }
210 mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }
211 netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }
212 oleo() { ${=BROWSER} "http://dict.leo.org/?search=$*" }
213 shtar() { gunzip -c $1 | tar -tf - -- | $PAGER }
214 shtgz() { tar -ztf $1 | $PAGER }
215 shzip() { unzip -l $1 | $PAGER }
216 sig() { agrep -d '^-- $' "$*" ~/.Signature }
217 swiki() { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }
218 udiff() { diff -urd $* | egrep -v "^Only in |^Binary files " }
219 viless() { vim --cmd 'let no_plugin_maps = 1' -c "so \$VIMRUNTIME/macros/less.vim" "${@:--}" }
220 wikide () { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }
221 wikien() { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
222 wodeb () { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
224 which google &>/dev/null && gex () { google "\"[ $1]\" $*" } # exact search at google
226 # download video from youtube
228 if ! [ -n "$2" ] ; then
229 print "Usage: ydtl http://youtube.com/watch?v=.... outputfile.flv">&2
232 wget -O${2} "http://youtube.com/get_video?"${${${"$(wget -o/dev/null -O- "${1}" | grep -e watch_fullscreen)"}##*watch_fullscreen\?}%%\&fs=*}
237 # Function Usage: doc packagename
238 doc() { cd /usr/share/doc/$1 && ls }
239 _doc() { _files -W /usr/share/doc -/ }
242 # make screenshot of current desktop (use 'import' from ImageMagic)
244 [[ ! -d ~/shots ]] && mkdir ~/shots
245 #cd ~/shots ; sleep 5 ; import -window root -depth 8 -quality 80 `date "+%Y-%m-%d--%H:%M:%S"`.png
246 cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg
252 images=( *.{jpg,gif,png}(.N) )
253 if [[ $#images -eq 0 ]] ; then
254 print "No image files found"
260 # create pdf file from source code
264 a2ps --medium A4dj -E -o $output $*
268 # zsh with perl-regex - use it e.g. via:
269 # regcheck '\s\d\.\d{3}\.\d{3} Euro' ' 1.000.000 Euro'
273 pcre_match $2 && echo "regex matches" || echo "regex does not match"
276 # list files which have been modified within the last x days
277 new() { print -l *(m-$1) }
280 greph () { history 0 | grep $1 }
281 (grep --help 2>/dev/null |grep -- --color) >/dev/null && \
282 alias grep='grep --color=auto' # use colors when GNU grep with color-support
283 alias GREP='grep -i --color=auto'
285 # one blank line between each line
286 if [ -r ~/.terminfo/m/mostlike ] ; then
287 # alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
288 man2() { PAGER='dash -c "sed G | /usr/bin/less"' TERM=mostlike /usr/bin/man "$@" ; }
291 # jump between directories
292 # Copyright 2005 Nikolai Weibull <nikolai@bitwi.se>
293 # notice: option AUTO_PUSHD has to be set
297 local color=$fg_bold[blue]
299 dirs -p | while read dir; do
300 local num="${$(printf "%-4d " $i)/ /.}"
301 printf " %s $color%s$reset_color\n" $num $dir
305 read -r 'dir?Jump to directory: ' || return
306 (( dir == -1 )) && return
307 if (( dir < 0 || dir >= i )); then
308 echo d: no such directory stack entry: $dir
314 # find out which libs define a symbol
315 # usage example: 'lcheck strcpy'
317 if [ -n "$1" ] ; then
318 nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
320 echo "Usage: lcheck <function>" >&2
326 FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
328 if [[ $NBFILES > 0 ]]; then
331 echo -n "Remove these files? [y/n] "
336 echo ">> $PWD purged, $NBFILES files removed"
338 echo "Ok. .. than not.."
344 # 'translate' looks up fot a word in a file with language-to-language
345 # translations (field separator should be " : "). A typical wordlist looks
347 # | english-word : german-transmission
348 # It's also only possible to translate english to german but not reciprocal.
349 # Use the following oneliner to turn back the sort order:
350 # $ awk -F ':' '{ print $2" : "$1" "$3 }' \
351 # /usr/local/lib/words/en-de.ISO-8859-1.vok > ~/.translate/de-en.ISO-8859-1.vok
354 -[dD]*) translate -l de-en $2
356 -[eE]*) translate -l en-de $2
359 echo "Usage: $0 { -D | -E }"
360 echo " -D == German to English"
361 echo " -E == English to German"
365 # Some quick Perl-hacks aka /useful/ oneliner
366 # bew() { perl -le 'print unpack "B*","'$1'"' }
367 # web() { perl -le 'print pack "B*","'$1'"' }
368 # hew() { perl -le 'print unpack "H*","'$1'"' }
369 # weh() { perl -le 'print pack "H*","'$1'"' }
370 # pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
371 # getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
372 # gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
373 # getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
374 # getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
375 # getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
376 # getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
377 # showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
378 # vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
379 # vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
381 # plap foo -- list all occurrences of program in the current PATH
385 echo "Usage: $0 program"
386 echo "Example: $0 zsh"
387 echo "Lists all occurrences of program in the current PATH."
389 ls -l ${^path}/*$1*(*N)
393 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
398 echo "Usage: $0 command"
401 cmd=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
402 print -l $cmd | less -F
403 echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
406 print -z "${cmd[$answer]#*$TAB}"
409 # Use vim to convert plaintext to HTML
410 2html() { vim -u NONE -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 &>/dev/null }
412 # Usage: simple-extract <file>
413 # Description: extracts archived files (maybe)
418 *.tar.bz2) bzip2 -v -d $1 ;;
419 *.tar.gz) tar -xvzf $1 ;;
422 *.bz2) bzip2 -d $1 ;;
424 *.gz) gunzip -d $1 ;;
425 *.tar) tar -xvf $1 ;;
426 *.tgz) gunzip -d $1 ;;
427 *.tbz2) tar -jxvf $1 ;;
429 *.Z) uncompress $1 ;;
430 *) echo "'$1' Error. Please go away" ;;
433 echo "'$1' is not a valid file"
437 # Usage: smartcompress <file> (<type>)
438 # Description: compresses files or a directory. Defaults to tar.gz
442 tgz | tar.gz) tar -zcvf$1.$2 $1 ;;
443 tbz2 | tar.bz2) tar -jcvf$1.$2 $1 ;;
444 tar.Z) tar -Zcvf$1.$2 $1 ;;
445 tar) tar -cvf$1.$2 $1 ;;
446 gz | gzip) gzip $1 ;;
447 bz2 | bzip2) bzip2 $1 ;;
449 echo "Error: $2 is not a valid compression type"
453 smartcompress $1 tar.gz
457 # Usage: show-archive <archive>
458 # Description: view archive without unpack
463 *.tar.gz) gunzip -c $1 | tar -tf - -- ;;
465 *.tgz) tar -ztf $1 ;;
466 *.zip) unzip -l $1 ;;
468 *) echo "'$1' Error. Please go away" ;;
471 echo "'$1' is not a valid archive"
477 if [[ -e $1 || -h $1 ]]; then
482 if [[ -e $file || -L $file ]]; then
483 if [[ -L $file ]]; then
484 echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
485 folsym `perl -le '$file = $ARGV[0];
486 $dest = readlink $file;
487 if ($dest !~ m{^/}) {
488 $file =~ s{(/?)[^/]*$}{$1$dest};
492 $file =~ s{/{2,}}{/}g;
493 while ($file =~ s{[^/]+/\.\./}{}) {
496 $file =~ s{^(/\.\.)+}{};
506 # Use 'view' to read manpages, if u want colors, regex - search, ...
508 # It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
509 vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
511 # search for various types or README file in dir and display them in $PAGER
512 # function readme() { $PAGER -- (#ia3)readme* }
515 files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
519 print 'No README files.'
523 # find all suid files in $PATH
524 # suidfind() { ls -latg $path | grep '^...s' }
525 suidfind() { ls -latg $path/*(sN) }
527 # See above but this is /better/ ... anywise ..
529 print 'Output will be written to ~/suid_* ...'
530 $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
531 $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
532 $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
533 $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
546 # a small check to see which DIR is located on which server/partition.
547 # stolen and modified from Sven's zshrc.forall
549 if [ -n "$1" ] ; then
551 if [ -d "$dir" ] ; then
552 ( cd $dir; echo "-<$dir>"; du -shx .; echo);
554 echo "warning: $dir does not exist" >&2
559 if [ -d "$dir" ] ; then
560 ( cd $dir; echo "-<$dir>"; du -shx .; echo);
562 echo "warning: $dir does not exist" >&2
568 # % slow_print `cat /etc/passwd`
570 for argument in "${@}"
572 for ((i = 1; i <= ${#1} ;i++)) {
573 print -n "${argument[i]}"
581 # display system state
584 print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
585 print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
586 print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
587 print "Login.: $LOGNAME (UID = $EUID) on $HOST"
588 print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
589 print "Uptime:$(uptime)"
597 cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
598 cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
599 echo " * Would you like to burn the cd now? (yes/no)"
602 [ "$input" = "yes" ]; then
603 echo " ! Burning Audio CD"
607 echo " ! Invalid response."
614 cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
615 echo " * Should I remove the temporary files? (yes/no)"
617 if [ "$input" = "yes" ]; then
618 echo " ! Removing Temporary Files."
623 echo " ! Invalid response."
627 # Make an audio CD from all mp3 files
630 for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
631 for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
632 for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
634 for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
637 # Create an ISO image. You are prompted for volume name, filename and directory
639 echo " * Volume name "
641 echo " * ISO Name (ie. tmp.iso)"
643 echo " * Directory or File"
645 mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
648 # simple thumbnails generator
650 rm -rf thumb-* index.html
654 <title>Images</title>
657 for f in *.(gif|jpeg|jpg|png)
659 convert -size 100x200 "$f" -resize 100x200 thumb-"$f"
660 echo " <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
664 </html>" >> index.html
667 # unset all limits (see zshbuiltins(1) /ulimit for details)
678 # ogg2mp3 with bitrate of 192
680 oggdec -o - ${1} | lame -b 192 - ${1:r}.mp3
683 # RFC 2396 URL encoding in Z-Shell
685 setopt localoptions extendedglob
687 print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
690 # get x-lite voip software
694 [ -d ~/tmp ] || mkdir ~/tmp
696 echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
697 if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
698 unp X-Lite_Install.tar.gz && echo done || echo failed
700 echo "Error while downloading." ; return 1
702 if [ -x xten-xlite/xtensoftphone ] ; then
703 echo "Execute xten-xlite/xtensoftphone to start xlite."
711 echo "Downloading debian package of skype."
712 echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
713 wget http://www.skype.com/go/getskype-linux-deb
714 $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
717 # get beta-version of skype
721 echo "Downloading debian package of skype (beta version)."
722 wget http://www.skype.com/go/getskype-linux-beta-deb
723 $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
726 # get gzimo (VoIP software)
730 echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
732 $SUDO apt-get install gconf2-common libgconf2-4
733 wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
734 $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
737 # get AIR - Automated Image and Restore
741 [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
743 wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
744 tar zxf air-$VER.tar.gz
746 INTERACTIVE=no $SUDO ./install-air-1.2.8
747 [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
750 # get specific git commitdiff
752 if [ -z $GITTREE ] ; then
753 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
755 if ! [ -z $1 ] ; then
756 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commitdiff;h=$1"
758 echo "Usage: git-get-diff <commit>"
762 # get specific git commit
764 if [ -z $GITTREE ] ; then
765 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
767 if ! [ -z $1 ] ; then
768 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commit;h=$1"
770 echo "Usage: git-get-commit <commit>"
774 # get specific git diff
775 git-get-plaindiff() {
776 if [ -z $GITTREE ] ; then
777 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
779 if ! [ -z $1 ] ; then
780 wget "http://kernel.org/git/?p=$GITTREE;a=commitdiff_plain;h=$1" -O $1.diff
782 echo 'Usage: git-get-plaindiff '
786 # log 'make install' output
787 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
789 [[ ! -d ~/.errorlogs ]] && mkdir ~/.errorlogs
790 =make -n install > ~/.errorlogs/${PWD##*/}-makelog
795 indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs $*
798 # highlight important stuff in diff output, usage example: hg diff | hidiff
799 [ -x $(which histring) ] && \
800 alias hidiff="histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'"
802 # rename pictures based on information found in exif headers
804 if [ $# -lt 1 ] ; then
805 echo 'Usage: jpgrename $FILES' >& 2
808 echo -n 'Checking for jhead with version newer than 1.9: '
809 jhead_version=`jhead -h | grep 'used by most Digital Cameras. v.*' | awk '{print $6}' | tr -d v`
810 if [[ $jhead_version > '1.9' ]]; then
811 echo 'success - now running jhead.'
812 jhead -n%Y-%m-%d_%Hh%M_%f $*
814 echo 'failed - exiting.'
819 # open file in vim and jump to line
820 # http://www.downgra.de/archives/2007/05/08/T19_21_11/
823 params=(${*//(#m):[0-9]*:/\\n+${MATCH//:/}}) # replace ':23:' to '\n+23'
824 params=(${(s|\n|)${(j|\n|)params}}) # join array using '\n', then split on all '\n'
828 # get_ic() - queries imap servers for capabilities; real simple. no imaps
831 if [[ ! -z $1 ]]; then
833 print "querying imap server on $1:${port}...\n";
834 print "a1 capability\na2 logout\n" | nc $1 ${port}
836 print "usage:\n $0 <imap-server> [port]"
840 # creates a Maildir/ with its {new,cur,tmp} subdirs
843 root=${MAILDIR_ROOT:-${HOME}/Mail}
844 if [[ -z ${1} ]] ; then print "Usage\n $0 <dirname>" ; fi
846 mkdir -p ${root}/${subdir}/{cur,new,tmp}
849 # xtrename() rename xterm from within GNU-screen
851 if [[ -z ${DISPLAY} ]] ; then
852 printf 'xtrename only makes sense in X11.\n'
855 if [[ -z ${1} ]] ; then
856 printf 'usage: xtrename() "title for xterm"\n'
857 printf ' renames the title of xterm from _within_ screen.\n'
858 printf ' Also works without screen.\n'
861 print -n "\eP\e]0;${1}\C-G\e\\"
865 # hl() highlighted less
866 # http://ft.bewatermyfriend.org/comp/data/zsh/zfunct.html
867 if [[ -x $(which highlight) ]] ; then
870 theme=${HL_THEME:-""}
873 ( printf 'available languages (syntax parameter):\n\n' ;
874 highlight --list-langs ; ) | less -SMr
877 ( printf 'available themes (style parameter):\n\n' ;
878 highlight --list-themes ; ) | less -SMr
881 printf 'usage: hl <syntax[:theme]> <file>\n'
882 printf ' available options: --list (-l), --themes (-t), --help (-h)\n\n'
883 printf ' Example: hl c main.c\n'
886 if [[ -z ${2} ]] || (( ${#argv} > 2 )) ; then
887 printf 'usage: hl <syntax[:theme]> <file>\n'
888 printf ' available options: --list (-l), --themes (-t), --help (-h)\n'
889 (( ${#argv} > 2 )) && printf ' Too many arguments.\n'
893 [[ ${1} == *:* ]] && [[ -n ${1#*:} ]] && theme=${1#*:}
894 if [[ -n ${theme} ]] ; then
895 highlight --xterm256 --syntax ${lang} --style ${theme} ${2} | less -SMr
897 highlight --ansi --syntax ${lang} ${2} | less -SMr
903 # ... and a proper completion for hl()
904 # needs 'highlight' as well, so it fits fine in here.
905 function _hl_genarg() {
907 if [[ -prefix 1 *: ]] ; then
909 themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*})
911 _wanted -C list themes expl theme compadd ${themes}
914 langs=(${${${(f)"$(LC_ALL=C highlight --list-langs)"}/ #/}:#*(Installed|Use name)*})
915 _wanted -C list languages expl languages compadd -S ':' -q ${langs}
918 function _hl_complete() {
919 _arguments -s '1: :_hl_genarg' '2:files:_path_files'
921 compdef _hl_complete hl
924 # create small urls via tinyurl.com using wget, grep and sed
926 [[ -z ${1} ]] && print "please give an url to shrink." && return 1
928 local tiny="http://tinyurl.com/create.php?url="
929 #print "${tiny}${url}" ; return
933 | grep -Eio 'value="(http://tinyurl.com/.*)"' \
934 | sed 's/value=//;s/"//g'
939 # mercurial related stuff {{{
940 if type -p hg &>/dev/null ; then
941 # gnu like diff for mercurial
942 # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
944 for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
947 # build debian package
948 alias hbp='hg-buildpackage'
950 # execute commands on the versioned patch-queue from the current repos
951 alias mq='hg -R $(readlink -f $(hg root)/.hg/patches)'
953 # diffstat for specific version of a mercurial repository
954 # hgstat => display diffstat between last revision and tip
955 # hgstat 1234 => display diffstat between revision 1234 and tip
957 [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
960 # get current mercurial tip via hg itself
964 if [ -f mercurial-tree/.hg ] ; then
966 echo "Running hg pull for retreiving latest version..."
968 echo "Finished update. Building mercurial"
970 echo "Setting \$PATH to $PWD:\$PATH..."
971 export PATH="$PWD:$PATH"
973 echo "Downloading mercurial via hg"
974 hg clone http://selenic.com/repo/hg mercurial-tree
976 echo "Building mercurial"
978 echo "Setting \$PATH to $PWD:\$PATH..."
979 export PATH="$PWD:$PATH"
980 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
981 # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
982 # export PYTHONPATH=${HOME}/lib/python
986 fi # end of check whether we have the 'hg'-executable
988 # get current mercurial snapshot
992 if [ -f mercurial-snapshot.tar.gz ] ; then
993 echo "mercurial-snapshot.tar.gz exists already, skipping download."
995 echo "Downloading mercurial snapshot"
996 wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
998 echo "Unpacking mercurial-snapshot.tar.gz"
999 tar zxf mercurial-snapshot.tar.gz
1000 cd mercurial-snapshot/
1001 echo "Installing required build-dependencies"
1002 $SUDO apt-get update
1003 $SUDO apt-get install python2.4-dev
1004 echo "Building mercurial"
1006 echo "Setting \$PATH to $PWD:\$PATH..."
1007 export PATH="$PWD:$PATH"
1008 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
1012 # some useful commands often hard to remember - let's grep for them {{{
1014 # Work around ion/xterm resize bug.
1015 #if [ "$SHLVL" = 1 ]; then
1016 # if [ -x `which resize 2>/dev/null` ]; then
1017 # eval `resize </dev/null`
1022 # /usr/bin/jackd -dalsa -dhw:0 -r48000 -p1024 -n2
1023 # now play audio file:
1024 # alsaplayer -o jack foobar.mp3
1026 # send files via netcat
1028 # send() {j=$*; tar cpz ${j/%${!#}/}|nc -w 1 ${!#} 51330;}
1030 # alias receive='nc -vlp 51330 | tar xzvp'
1033 # dh_make -e foo@localhost -f $1
1034 # dpkg-buildpackage -rfakeroot
1036 # dpkg-scanpackages ./ /dev/null | gzip > Packages.gz
1037 # dpkg-scansources . | gzip > Sources.gz
1038 # grep-dctrl --field Maintainer $* /var/lib/apt/lists/*
1041 # convert -geometry 200x200 -interlace LINE -verbose
1042 # ldapsearch -x -b "OU=Bedienstete,O=tug" -h ldap.tugraz.at sn=$1
1043 # ps -ao user,pcpu,start,command
1044 # gpg --keyserver blackhole.pca.dfn.de --recv-keys
1045 # xterm -bg black -fg yellow -fn -misc-fixed-medium-r-normal--14-140-75-75-c-90-iso8859-15 -ah
1046 # nc -vz $1 1-1024 # portscan via netcat
1047 # wget --mirror --no-parent --convert-links
1049 # autoload -U tetris; zle -N tetris; bindkey '...' ; echo "press ... for playing tennis"
1051 # modify console cursor
1052 # see http://www.tldp.org/HOWTO/Framebuffer-HOWTO-5.html
1053 # print $'\e[?96;0;64c'
1056 # finally source a local zshrc and grmlsmall-specific configuration {{{
1058 # The following file is used to remove zsh-config-items that do not work
1059 # in grml-small by default.
1060 # If you do not want these adjustments (for whatever reason),
1061 # there are three ways to accomplish that:
1062 # a) at the beginning of this file (variables section), set
1063 # $GRMLSMALL_SPECIFIC to 0 or comment out the variable definition.
1064 # b) remove/rename .zshrc.grmlsmall
1065 # c) comment out the following line
1066 (( GRMLSMALL_SPECIFIC > 0 )) && isgrmlsmall && source ~/.zshrc.grmlsmall
1068 # this allows us to stay in sync with /etc/skel/.zshrc
1069 # through 'ln -s /etc/skel/.zshrc ~/.zshrc' and put own
1070 # modifications in ~/.zshrc.local
1071 if [ -r ~/.zshrc.local ] ; then
1076 ## END OF FILE #################################################################
1077 # vim:foldmethod=marker