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: Die Mai 15 11:21:56 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 # autoloading stuff {{{
19 # associate types and extensions:
20 autoload zsh-mime-setup && zsh-mime-setup
23 # completion system {{{
24 # just make sure it is loaded in this file too
25 type compinit &>/dev/null || { autoload -U compinit && compinit }
28 # make sure isgrmlsmall is defined {{{
29 type isgrmlsmall &>/dev/null || function isgrmlsmall () { return 1 }
34 # do you want grmlsmall-specific adjustments?
37 # set terminal property (used e.g. by msgid-chooser)
38 export COLORTERM="yes"
41 if [ -z "$BROWSER" ] ; then
42 if [ -n "$DISPLAY" ] ; then
43 [ -x $(which firefox) ] && export BROWSER=firefox
45 [ -x $(which w3m) ] && export BROWSER=w3m
48 (( ${+PAGER} )) || export PAGER="less"
51 [ -d /usr/share/qt3 ] && export QTDIR=/usr/share/qt3
52 [ -d /usr/share/qt4 ] && export QTDIR=/usr/share/qt4
54 # support running 'jikes *.java && jamvm HelloWorld' OOTB:
55 [ -f /usr/share/classpath/glibj.zip ] && export JIKESPATH=/usr/share/classpath/glibj.zip
60 # Allow comments even in interactive shells i. e.
61 # $ uname # This command prints system informations
63 # $ setopt interactivecomments
64 # $ uname # This command prints system informations
66 # setopt interactivecomments
68 # ctrl-s will no longer freeze the terminal.
74 # These do not have to be at the beginning of the command line.
75 # Avoid typing cd ../../ for going two dirs down and so on
76 # Usage, e.g.: "$ cd ...' or just '$ ...' with 'setopt auto_cd'
77 # Notice: deactivated by 061112 by default, we use another approach
78 # known as "power completion / abbreviation expansion"
79 # alias -g '...'='../..'
80 # alias -g '....'='../../..'
81 # alias -g BG='& exit'
85 # alias -g Hl=' --help |& less -r'
88 # alias -g LL='|& less -r'
90 # alias -g N='&>/dev/null'
91 # alias -g R='| tr A-z N-za-m'
92 # alias -g SL='| sort | less'
95 # alias -g V='| vim -'
101 # Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
102 alias hide='echo -en "\033]50;nil2\007"'
103 alias tiny='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-80-*-*-c-*-iso8859-15\007"'
104 alias small='echo -en "\033]50;6x10\007"'
105 alias medium='echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-15\007"'
106 alias default='echo -e "\033]50;-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-15\007"'
107 alias large='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-150-*-*-c-*-iso8859-15\007"'
108 alias huge='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-210-*-*-c-*-iso8859-15\007"'
109 alias smartfont='echo -en "\033]50;-artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*\007"'
110 alias semifont='echo -en "\033]50;-misc-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-15\007"'
111 # if [ "$TERM" = "xterm" ] && [ "$LINES" -ge 50 ] && [ "$COLUMNS" -ge 100 ] && [ -z "$SSH_CONNECTION" ]; then
118 # alias u='translate -i' # translate
121 alias CO="./configure"
122 alias CH="./configure --help"
124 # http://conkeror.mozdev.org/
125 alias conkeror='firefox -chrome chrome://conkeror/content'
128 if type -p tla &>/dev/null ; then
129 alias tdi='tla what-changed --diffs | less'
130 alias tbp='tla-buildpackage'
131 alias tmi='tla archive-mirror'
132 alias tco='tla commit'
133 alias tme='tla star-merge'
137 alias dir="ls -lSrah"
138 alias lad='ls -d .*(/)' # only show dot-directories
139 alias lsa='ls -a .*(.)' # only show dot-files
140 alias lss='ls -l *(s,S,t)' # only files with setgid/setuid/sticky flag
141 alias lsl='ls -l *(@[1,10])' # only symlinks
142 alias lsx='ls -l *(*[1,10])' # only executables
143 alias lsw='ls -ld *(R,W,X.^ND/)' # world-{readable,writable,executable} files
144 alias lsbig="ls -flh *(.OL[1,10])" # display the biggest files
145 alias lsd='ls -d *(/)' # only show directories
146 alias lse='ls -d *(/^F)' # only show empty directories
147 alias lsnew="ls -rl *(D.om[1,10])" # display the newest files
148 alias lsold="ls -rtlh *(D.om[1,10])" # display the oldest files
149 alias lssmall="ls -Srl *(.oL[1,10])" # display the smallest files
152 alias rw-='chmod 600'
153 alias rwx='chmod 700'
154 alias r--='chmod 644'
155 alias r-x='chmod 755'
157 # some useful aliases
161 alias cmplayer='mplayer -vo fbdev'
162 alias fbmplayer='mplayer -vo fbdev -fs -zoom'
163 alias fblinks='links2 -driver fb'
165 # ignore ~/.ssh/known_hosts entries
166 # alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
167 alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
168 alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
170 # use colors when browsing man pages (if not using pinfo or PAGER=most)
171 [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
173 # check whether Debian's package management (dpkg) is running
174 salias check_dpkg_running="dpkg_running"
176 # work around non utf8 capable software in utf environment
177 if [ -x /usr/bin/mrxvt ] ; then
178 isutfenv && [ -n "$LANG" ] && alias mrxvt="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} mrxvt"
181 if [ -x /usr/bin/aterm ] ; then
182 isutfenv && [ -n "$LANG" ] && alias aterm="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} aterm"
185 if [ -x /usr/bin/centericq ] ; then
186 isutfenv && [ -n "$LANG" ] && alias centericq="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} centericq"
190 ## useful functions {{{
192 # functions without detailed explanation:
193 agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
194 bk() { cp -b ${1} ${1}_`date --iso-8601=m` }
195 cdiff() { diff -crd "$*" | egrep -v "^Only in |^Binary files " }
196 cl() { cd $1 && ls -a } # cd && ls
197 cvsa() { cvs add $* && cvs com -m 'initial checkin' $* }
198 cvsd() { cvs diff -N $* |& $PAGER }
199 cvsl() { cvs log $* |& $PAGER }
200 cvsq() { cvs -nq update }
201 cvsr() { rcs2log $* | $PAGER }
202 cvss() { cvs status -v $* }
203 debbug() { ${=BROWSER} "http://bugs.debian.org/$*" }
204 debbugm() { bts show --mbox $1 } # provide bugnummer as "$1"
205 disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null }
206 dmoz() { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
207 dwicti() { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }
208 ewicti() { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }
209 fir() { firefox -a firefox -remote "openURL($1)" }
210 ggogle() { ${=BROWSER} "http://groups.google.com/groups?q=$*" }
211 google() { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }
212 mcd() { mkdir -p "$@"; cd "$@" } # mkdir && cd
213 mdiff() { diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1" }
214 memusage(){ ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc }
215 mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }
216 netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }
217 oleo() { ${=BROWSER} "http://dict.leo.org/?search=$*" }
218 shtar() { gunzip -c $1 | tar -tf - -- | $PAGER }
219 shtgz() { tar -ztf $1 | $PAGER }
220 shzip() { unzip -l $1 | $PAGER }
221 sig() { agrep -d '^-- $' "$*" ~/.Signature }
222 swiki() { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }
223 udiff() { diff -urd $* | egrep -v "^Only in |^Binary files " }
224 viless() { vim --cmd 'let no_plugin_maps = 1' -c "so \$VIMRUNTIME/macros/less.vim" "${@:--}" }
225 wikide () { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }
226 wikien() { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
227 wodeb () { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
229 which google &>/dev/null && gex () { google "\"[ $1]\" $*" } # exact search at google
231 # download video from youtube
233 if ! [ -n "$2" ] ; then
234 print "Usage: ydtl http://youtube.com/watch?v=.... outputfile.flv">&2
237 wget -O${2} "http://youtube.com/get_video?"${${${"$(wget -o/dev/null -O- "${1}" | grep -e watch_fullscreen)"}##*watch_fullscreen\?}%%\&fs=*}
242 # Function Usage: doc packagename
243 doc() { cd /usr/share/doc/$1 && ls }
244 _doc() { _files -W /usr/share/doc -/ }
247 # make screenshot of current desktop (use 'import' from ImageMagic)
249 [[ ! -d ~/shots ]] && mkdir ~/shots
250 #cd ~/shots ; sleep 5 ; import -window root -depth 8 -quality 80 `date "+%Y-%m-%d--%H:%M:%S"`.png
251 cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg
257 images=( *.{jpg,gif,png}(.N) )
258 if [[ $#images -eq 0 ]] ; then
259 print "No image files found"
265 # create pdf file from source code
269 a2ps --medium A4dj -E -o $output $*
273 # zsh with perl-regex - use it e.g. via:
274 # regcheck '\s\d\.\d{3}\.\d{3} Euro' ' 1.000.000 Euro'
278 pcre_match $2 && echo "regex matches" || echo "regex does not match"
281 # list files which have been modified within the last x days
282 new() { print -l *(m-$1) }
285 greph () { history 0 | grep $1 }
286 (grep --help 2>/dev/null |grep -- --color) >/dev/null && \
287 alias grep='grep --color=auto' # use colors when GNU grep with color-support
288 alias GREP='grep -i --color=auto'
290 # one blank line between each line
291 if [ -r ~/.terminfo/m/mostlike ] ; then
292 # alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
293 man2() { PAGER='dash -c "sed G | /usr/bin/less"' TERM=mostlike /usr/bin/man "$@" ; }
296 # jump between directories
297 # Copyright 2005 Nikolai Weibull <nikolai@bitwi.se>
298 # notice: option AUTO_PUSHD has to be set
302 local color=$fg_bold[blue]
304 dirs -p | while read dir; do
305 local num="${$(printf "%-4d " $i)/ /.}"
306 printf " %s $color%s$reset_color\n" $num $dir
310 read -r 'dir?Jump to directory: ' || return
311 (( dir == -1 )) && return
312 if (( dir < 0 || dir >= i )); then
313 echo d: no such directory stack entry: $dir
319 # find out which libs define a symbol
320 # usage example: 'lcheck strcpy'
322 if [ -n "$1" ] ; then
323 nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
325 echo "Usage: lcheck <function>" >&2
331 FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
333 if [[ $NBFILES > 0 ]]; then
336 echo -n "Remove these files? [y/n] "
341 echo ">> $PWD purged, $NBFILES files removed"
343 echo "Ok. .. than not.."
349 # 'translate' looks up fot a word in a file with language-to-language
350 # translations (field separator should be " : "). A typical wordlist looks
352 # | english-word : german-transmission
353 # It's also only possible to translate english to german but not reciprocal.
354 # Use the following oneliner to turn back the sort order:
355 # $ awk -F ':' '{ print $2" : "$1" "$3 }' \
356 # /usr/local/lib/words/en-de.ISO-8859-1.vok > ~/.translate/de-en.ISO-8859-1.vok
359 -[dD]*) translate -l de-en $2
361 -[eE]*) translate -l en-de $2
364 echo "Usage: $0 { -D | -E }"
365 echo " -D == German to English"
366 echo " -E == English to German"
370 # Some quick Perl-hacks aka /useful/ oneliner
371 # bew() { perl -le 'print unpack "B*","'$1'"' }
372 # web() { perl -le 'print pack "B*","'$1'"' }
373 # hew() { perl -le 'print unpack "H*","'$1'"' }
374 # weh() { perl -le 'print pack "H*","'$1'"' }
375 # pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
376 # getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
377 # gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
378 # getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
379 # getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
380 # getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
381 # getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
382 # showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
383 # vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
384 # vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
386 # plap foo -- list all occurrences of program in the current PATH
390 echo "Usage: $0 program"
391 echo "Example: $0 zsh"
392 echo "Lists all occurrences of program in the current PATH."
394 ls -l ${^path}/*$1*(*N)
398 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
403 echo "Usage: $0 command"
406 cmd=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
407 print -l $cmd | less -F
408 echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
411 print -z "${cmd[$answer]#*$TAB}"
414 # Use vim to convert plaintext to HTML
415 2html() { vim -u NONE -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 &>/dev/null }
417 # Usage: simple-extract <file>
418 # Description: extracts archived files (maybe)
423 *.tar.bz2) bzip2 -v -d $1 ;;
424 *.tar.gz) tar -xvzf $1 ;;
427 *.bz2) bzip2 -d $1 ;;
429 *.gz) gunzip -d $1 ;;
430 *.tar) tar -xvf $1 ;;
431 *.tgz) gunzip -d $1 ;;
432 *.tbz2) tar -jxvf $1 ;;
434 *.Z) uncompress $1 ;;
435 *) echo "'$1' Error. Please go away" ;;
438 echo "'$1' is not a valid file"
442 # Usage: smartcompress <file> (<type>)
443 # Description: compresses files or a directory. Defaults to tar.gz
447 tgz | tar.gz) tar -zcvf$1.$2 $1 ;;
448 tbz2 | tar.bz2) tar -jcvf$1.$2 $1 ;;
449 tar.Z) tar -Zcvf$1.$2 $1 ;;
450 tar) tar -cvf$1.$2 $1 ;;
451 gz | gzip) gzip $1 ;;
452 bz2 | bzip2) bzip2 $1 ;;
454 echo "Error: $2 is not a valid compression type"
458 smartcompress $1 tar.gz
462 # Usage: show-archive <archive>
463 # Description: view archive without unpack
468 *.tar.gz) gunzip -c $1 | tar -tf - -- ;;
470 *.tgz) tar -ztf $1 ;;
471 *.zip) unzip -l $1 ;;
473 *) echo "'$1' Error. Please go away" ;;
476 echo "'$1' is not a valid archive"
482 if [[ -e $1 || -h $1 ]]; then
487 if [[ -e $file || -L $file ]]; then
488 if [[ -L $file ]]; then
489 echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
490 folsym `perl -le '$file = $ARGV[0];
491 $dest = readlink $file;
492 if ($dest !~ m{^/}) {
493 $file =~ s{(/?)[^/]*$}{$1$dest};
497 $file =~ s{/{2,}}{/}g;
498 while ($file =~ s{[^/]+/\.\./}{}) {
501 $file =~ s{^(/\.\.)+}{};
511 # Use 'view' to read manpages, if u want colors, regex - search, ...
513 # It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
514 vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
516 # search for various types or README file in dir and display them in $PAGER
517 # function readme() { $PAGER -- (#ia3)readme* }
520 files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
524 print 'No README files.'
528 # find all suid files in $PATH
529 # suidfind() { ls -latg $path | grep '^...s' }
530 suidfind() { ls -latg $path/*(sN) }
532 # See above but this is /better/ ... anywise ..
534 print 'Output will be written to ~/suid_* ...'
535 $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
536 $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
537 $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
538 $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
551 # a small check to see which DIR is located on which server/partition.
552 # stolen and modified from Sven's zshrc.forall
554 if [ -n "$1" ] ; then
556 if [ -d "$dir" ] ; then
557 ( cd $dir; echo "-<$dir>"; du -shx .; echo);
559 echo "warning: $dir does not exist" >&2
564 if [ -d "$dir" ] ; then
565 ( cd $dir; echo "-<$dir>"; du -shx .; echo);
567 echo "warning: $dir does not exist" >&2
573 # % slow_print `cat /etc/passwd`
575 for argument in "${@}"
577 for ((i = 1; i <= ${#1} ;i++)) {
578 print -n "${argument[i]}"
586 # display system state
589 print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
590 print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
591 print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
592 print "Login.: $LOGNAME (UID = $EUID) on $HOST"
593 print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
594 print "Uptime:$(uptime)"
602 cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
603 cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
604 echo " * Would you like to burn the cd now? (yes/no)"
607 [ "$input" = "yes" ]; then
608 echo " ! Burning Audio CD"
612 echo " ! Invalid response."
619 cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
620 echo " * Should I remove the temporary files? (yes/no)"
622 if [ "$input" = "yes" ]; then
623 echo " ! Removing Temporary Files."
628 echo " ! Invalid response."
632 # Make an audio CD from all mp3 files
635 for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
636 for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
637 for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
639 for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
642 # Create an ISO image. You are prompted for volume name, filename and directory
644 echo " * Volume name "
646 echo " * ISO Name (ie. tmp.iso)"
648 echo " * Directory or File"
650 mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
653 # simple thumbnails generator
655 rm -rf thumb-* index.html
659 <title>Images</title>
662 for f in *.(gif|jpeg|jpg|png)
664 convert -size 100x200 "$f" -resize 100x200 thumb-"$f"
665 echo " <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
669 </html>" >> index.html
672 # unset all limits (see zshbuiltins(1) /ulimit for details)
683 # ogg2mp3 with bitrate of 192
685 oggdec -o - ${1} | lame -b 192 - ${1:r}.mp3
688 # RFC 2396 URL encoding in Z-Shell
690 setopt localoptions extendedglob
692 print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
695 # get x-lite voip software
699 [ -d ~/tmp ] || mkdir ~/tmp
701 echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
702 if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
703 unp X-Lite_Install.tar.gz && echo done || echo failed
705 echo "Error while downloading." ; return 1
707 if [ -x xten-xlite/xtensoftphone ] ; then
708 echo "Execute xten-xlite/xtensoftphone to start xlite."
716 echo "Downloading debian package of skype."
717 echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
718 wget http://www.skype.com/go/getskype-linux-deb
719 $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
722 # get beta-version of skype
726 echo "Downloading debian package of skype (beta version)."
727 wget http://www.skype.com/go/getskype-linux-beta-deb
728 $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
731 # get gzimo (VoIP software)
735 echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
737 $SUDO apt-get install gconf2-common libgconf2-4
738 wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
739 $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
742 # get AIR - Automated Image and Restore
746 [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
748 wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
749 tar zxf air-$VER.tar.gz
751 INTERACTIVE=no $SUDO ./install-air-1.2.8
752 [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
755 # get specific git commitdiff
757 if [ -z $GITTREE ] ; then
758 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
760 if ! [ -z $1 ] ; then
761 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commitdiff;h=$1"
763 echo "Usage: git-get-diff <commit>"
767 # get specific git commit
769 if [ -z $GITTREE ] ; then
770 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
772 if ! [ -z $1 ] ; then
773 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commit;h=$1"
775 echo "Usage: git-get-commit <commit>"
779 # get specific git diff
780 git-get-plaindiff() {
781 if [ -z $GITTREE ] ; then
782 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
784 if ! [ -z $1 ] ; then
785 wget "http://kernel.org/git/?p=$GITTREE;a=commitdiff_plain;h=$1" -O $1.diff
787 echo 'Usage: git-get-plaindiff '
791 # log 'make install' output
792 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
794 [[ ! -d ~/.errorlogs ]] && mkdir ~/.errorlogs
795 =make -n install > ~/.errorlogs/${PWD##*/}-makelog
800 indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs $*
803 # highlight important stuff in diff output, usage example: hg diff | hidiff
804 [ -x $(which histring) ] && \
805 alias hidiff="histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'"
807 # rename pictures based on information found in exif headers
809 if [ $# -lt 1 ] ; then
810 echo 'Usage: jpgrename $FILES' >& 2
813 echo -n 'Checking for jhead with version newer than 1.9: '
814 jhead_version=`jhead -h | grep 'used by most Digital Cameras. v.*' | awk '{print $6}' | tr -d v`
815 if [[ $jhead_version > '1.9' ]]; then
816 echo 'success - now running jhead.'
817 jhead -n%Y-%m-%d_%Hh%M_%f $*
819 echo 'failed - exiting.'
824 # open file in vim and jump to line
825 # http://www.downgra.de/archives/2007/05/08/T19_21_11/
828 params=(${*//(#m):[0-9]*:/\\n+${MATCH//:/}}) # replace ':23:' to '\n+23'
829 params=(${(s|\n|)${(j|\n|)params}}) # join array using '\n', then split on all '\n'
833 # get_ic() - queries imap servers for capabilities; real simple. no imaps
836 if [[ ! -z $1 ]]; then
838 print "querying imap server on $1:${port}...\n";
839 print "a1 capability\na2 logout\n" | nc $1 ${port}
841 print "usage:\n $0 <imap-server> [port]"
845 # creates a Maildir/ with its {new,cur,tmp} subdirs
848 root=${MAILDIR_ROOT:-${HOME}/Mail}
849 if [[ -z ${1} ]] ; then print "Usage\n $0 <dirname>" ; fi
851 mkdir -p ${root}/${subdir}/{cur,new,tmp}
854 # xtrename() rename xterm from within GNU-screen
856 if [[ -z ${DISPLAY} ]] ; then
857 printf 'xtrename only makes sense in X11.\n'
860 if [[ -z ${1} ]] ; then
861 printf 'usage: xtrename() "title for xterm"\n'
862 printf ' renames the title of xterm from _within_ screen.\n'
863 printf ' Also works without screen.\n'
866 print -n "\eP\e]0;${1}\C-G\e\\"
870 # hl() highlighted less
871 # http://ft.bewatermyfriend.org/comp/data/zsh/zfunct.html
872 if [[ -x $(which highlight) ]] ; then
875 theme=${HL_THEME:-""}
878 ( printf 'available languages (syntax parameter):\n\n' ;
879 highlight --list-langs ; ) | less -SMr
882 ( printf 'available themes (style parameter):\n\n' ;
883 highlight --list-themes ; ) | less -SMr
886 printf 'usage: hl <syntax[:theme]> <file>\n'
887 printf ' available options: --list (-l), --themes (-t), --help (-h)\n\n'
888 printf ' Example: hl c main.c\n'
891 if [[ -z ${2} ]] || (( ${#argv} > 2 )) ; then
892 printf 'usage: hl <syntax[:theme]> <file>\n'
893 printf ' available options: --list (-l), --themes (-t), --help (-h)\n'
894 (( ${#argv} > 2 )) && printf ' Too many arguments.\n'
898 [[ ${1} == *:* ]] && [[ -n ${1#*:} ]] && theme=${1#*:}
899 if [[ -n ${theme} ]] ; then
900 highlight --xterm256 --syntax ${lang} --style ${theme} ${2} | less -SMr
902 highlight --ansi --syntax ${lang} ${2} | less -SMr
908 # ... and a proper completion for hl()
909 # needs 'highlight' as well, so it fits fine in here.
910 function _hl_genarg() {
912 if [[ -prefix 1 *: ]] ; then
914 themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*})
916 _wanted -C list themes expl theme compadd ${themes}
919 langs=(${${${(f)"$(LC_ALL=C highlight --list-langs)"}/ #/}:#*(Installed|Use name)*})
920 _wanted -C list languages expl languages compadd -S ':' -q ${langs}
923 function _hl_complete() {
924 _arguments -s '1: :_hl_genarg' '2:files:_path_files'
926 compdef _hl_complete hl
929 # create small urls via tinyurl.com using wget, grep and sed
931 [[ -z ${1} ]] && print "please give an url to shrink." && return 1
933 local tiny="http://tinyurl.com/create.php?url="
934 #print "${tiny}${url}" ; return
938 | grep -Eio 'value="(http://tinyurl.com/.*)"' \
939 | sed 's/value=//;s/"//g'
944 # mercurial related stuff {{{
945 if type -p hg &>/dev/null ; then
946 # gnu like diff for mercurial
947 # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
949 for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
952 # build debian package
953 alias hbp='hg-buildpackage'
955 # execute commands on the versioned patch-queue from the current repos
956 alias mq='hg -R $(readlink -f $(hg root)/.hg/patches)'
958 # diffstat for specific version of a mercurial repository
959 # hgstat => display diffstat between last revision and tip
960 # hgstat 1234 => display diffstat between revision 1234 and tip
962 [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
965 # get current mercurial tip via hg itself
969 if [ -f mercurial-tree/.hg ] ; then
971 echo "Running hg pull for retreiving latest version..."
973 echo "Finished update. Building mercurial"
975 echo "Setting \$PATH to $PWD:\$PATH..."
976 export PATH="$PWD:$PATH"
978 echo "Downloading mercurial via hg"
979 hg clone http://selenic.com/repo/hg mercurial-tree
981 echo "Building mercurial"
983 echo "Setting \$PATH to $PWD:\$PATH..."
984 export PATH="$PWD:$PATH"
985 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
986 # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
987 # export PYTHONPATH=${HOME}/lib/python
991 fi # end of check whether we have the 'hg'-executable
993 # get current mercurial snapshot
997 if [ -f mercurial-snapshot.tar.gz ] ; then
998 echo "mercurial-snapshot.tar.gz exists already, skipping download."
1000 echo "Downloading mercurial snapshot"
1001 wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
1003 echo "Unpacking mercurial-snapshot.tar.gz"
1004 tar zxf mercurial-snapshot.tar.gz
1005 cd mercurial-snapshot/
1006 echo "Installing required build-dependencies"
1007 $SUDO apt-get update
1008 $SUDO apt-get install python2.4-dev
1009 echo "Building mercurial"
1011 echo "Setting \$PATH to $PWD:\$PATH..."
1012 export PATH="$PWD:$PATH"
1013 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
1017 # some useful commands often hard to remember - let's grep for them {{{
1019 # Work around ion/xterm resize bug.
1020 #if [ "$SHLVL" = 1 ]; then
1021 # if [ -x `which resize 2>/dev/null` ]; then
1022 # eval `resize </dev/null`
1027 # /usr/bin/jackd -dalsa -dhw:0 -r48000 -p1024 -n2
1028 # now play audio file:
1029 # alsaplayer -o jack foobar.mp3
1031 # send files via netcat
1033 # send() {j=$*; tar cpz ${j/%${!#}/}|nc -w 1 ${!#} 51330;}
1035 # alias receive='nc -vlp 51330 | tar xzvp'
1038 # dh_make -e foo@localhost -f $1
1039 # dpkg-buildpackage -rfakeroot
1041 # dpkg-scanpackages ./ /dev/null | gzip > Packages.gz
1042 # dpkg-scansources . | gzip > Sources.gz
1043 # grep-dctrl --field Maintainer $* /var/lib/apt/lists/*
1046 # convert -geometry 200x200 -interlace LINE -verbose
1047 # ldapsearch -x -b "OU=Bedienstete,O=tug" -h ldap.tugraz.at sn=$1
1048 # ps -ao user,pcpu,start,command
1049 # gpg --keyserver blackhole.pca.dfn.de --recv-keys
1050 # xterm -bg black -fg yellow -fn -misc-fixed-medium-r-normal--14-140-75-75-c-90-iso8859-15 -ah
1051 # nc -vz $1 1-1024 # portscan via netcat
1052 # wget --mirror --no-parent --convert-links
1054 # autoload -U tetris; zle -N tetris; bindkey '...' ; echo "press ... for playing tennis"
1056 # modify console cursor
1057 # see http://www.tldp.org/HOWTO/Framebuffer-HOWTO-5.html
1058 # print $'\e[?96;0;64c'
1061 # finally source a local zshrc and grmlsmall-specific configuration {{{
1063 # The following file is used to remove zsh-config-items that do not work
1064 # in grml-small by default.
1065 # If you do not want these adjustments (for whatever reason),
1066 # there are three ways to accomplish that:
1067 # a) at the beginning of this file (variables section), set
1068 # $GRMLSMALL_SPECIFIC to 0 or comment out the variable definition.
1069 # b) remove/rename .zshrc.grmlsmall
1070 # c) comment out the following line
1071 (( GRMLSMALL_SPECIFIC > 0 )) && isgrmlsmall && source ~/.zshrc.grmlsmall
1073 # this allows us to stay in sync with /etc/skel/.zshrc
1074 # through 'ln -s /etc/skel/.zshrc ~/.zshrc' and put own
1075 # modifications in ~/.zshrc.local
1076 if [ -r ~/.zshrc.local ] ; then
1081 ## END OF FILE #################################################################
1082 # vim:foldmethod=marker