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: Fre Mai 25 01:27:47 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
160 [ -x $(which ipython) ] && alias ips='ipython -p sh'
163 alias cmplayer='mplayer -vo fbdev'
164 alias fbmplayer='mplayer -vo fbdev -fs -zoom'
165 alias fblinks='links2 -driver fb'
167 # ignore ~/.ssh/known_hosts entries
168 # alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
169 alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
170 alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
172 # use colors when browsing man pages (if not using pinfo or PAGER=most)
173 [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
175 # check whether Debian's package management (dpkg) is running
176 salias check_dpkg_running="dpkg_running"
178 # work around non utf8 capable software in utf environment
179 if [ -x $(which mrxvt) ] ; then
180 isutfenv && [ -n "$LANG" ] && alias mrxvt="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} mrxvt"
183 if [ -x $(which aterm) ] ; then
184 isutfenv && [ -n "$LANG" ] && alias aterm="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} aterm"
187 if [ -x $(which centericq) ] ; then
188 isutfenv && [ -n "$LANG" ] && alias centericq="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} centericq"
192 ## useful functions {{{
194 # functions without detailed explanation:
195 agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
196 bk() { cp -b ${1} ${1}_`date --iso-8601=m` }
197 cdiff() { diff -crd "$*" | egrep -v "^Only in |^Binary files " }
198 cl() { cd $1 && ls -a } # cd && ls
199 cvsa() { cvs add $* && cvs com -m 'initial checkin' $* }
200 cvsd() { cvs diff -N $* |& $PAGER }
201 cvsl() { cvs log $* |& $PAGER }
202 cvsq() { cvs -nq update }
203 cvsr() { rcs2log $* | $PAGER }
204 cvss() { cvs status -v $* }
205 debbug() { ${=BROWSER} "http://bugs.debian.org/$*" }
206 debbugm() { bts show --mbox $1 } # provide bugnummer as "$1"
207 disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null }
208 dmoz() { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
209 dwicti() { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }
210 ewicti() { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }
211 fir() { firefox -a firefox -remote "openURL($1)" }
212 ggogle() { ${=BROWSER} "http://groups.google.com/groups?q=$*" }
213 google() { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }
214 mcd() { mkdir -p "$@"; cd "$@" } # mkdir && cd
215 mdiff() { diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1" }
216 memusage(){ ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc }
217 mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }
218 netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }
219 oleo() { ${=BROWSER} "http://dict.leo.org/?search=$*" }
220 shtar() { gunzip -c $1 | tar -tf - -- | $PAGER }
221 shtgz() { tar -ztf $1 | $PAGER }
222 shzip() { unzip -l $1 | $PAGER }
223 sig() { agrep -d '^-- $' "$*" ~/.Signature }
224 swiki() { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }
225 udiff() { diff -urd $* | egrep -v "^Only in |^Binary files " }
226 viless() { vim --cmd 'let no_plugin_maps = 1' -c "so \$VIMRUNTIME/macros/less.vim" "${@:--}" }
227 wikide () { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }
228 wikien() { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
229 wodeb () { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
231 which google &>/dev/null && gex () { google "\"[ $1]\" $*" } # exact search at google
233 # download video from youtube
235 if ! [ -n "$2" ] ; then
236 print "Usage: ydtl http://youtube.com/watch?v=.... outputfile.flv">&2
239 wget -O${2} "http://youtube.com/get_video?"${${${"$(wget -o/dev/null -O- "${1}" | grep -e watch_fullscreen)"}##*watch_fullscreen\?}%%\&fs=*}
244 # Function Usage: doc packagename
245 doc() { cd /usr/share/doc/$1 && ls }
246 _doc() { _files -W /usr/share/doc -/ }
249 # make screenshot of current desktop (use 'import' from ImageMagic)
251 [[ ! -d ~/shots ]] && mkdir ~/shots
252 #cd ~/shots ; sleep 5 ; import -window root -depth 8 -quality 80 `date "+%Y-%m-%d--%H:%M:%S"`.png
253 cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg
259 images=( *.{jpg,gif,png}(.N) )
260 if [[ $#images -eq 0 ]] ; then
261 print "No image files found"
267 # create pdf file from source code
271 a2ps --medium A4dj -E -o $output $*
275 # zsh with perl-regex - use it e.g. via:
276 # regcheck '\s\d\.\d{3}\.\d{3} Euro' ' 1.000.000 Euro'
280 pcre_match $2 && echo "regex matches" || echo "regex does not match"
283 # list files which have been modified within the last x days
284 new() { print -l *(m-$1) }
287 greph () { history 0 | grep $1 }
288 (grep --help 2>/dev/null |grep -- --color) >/dev/null && \
289 alias grep='grep --color=auto' # use colors when GNU grep with color-support
290 alias GREP='grep -i --color=auto'
292 # one blank line between each line
293 if [ -r ~/.terminfo/m/mostlike ] ; then
294 # alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
295 man2() { PAGER='dash -c "sed G | /usr/bin/less"' TERM=mostlike /usr/bin/man "$@" ; }
298 # jump between directories
299 # Copyright 2005 Nikolai Weibull <nikolai@bitwi.se>
300 # notice: option AUTO_PUSHD has to be set
304 local color=$fg_bold[blue]
306 dirs -p | while read dir; do
307 local num="${$(printf "%-4d " $i)/ /.}"
308 printf " %s $color%s$reset_color\n" $num $dir
312 read -r 'dir?Jump to directory: ' || return
313 (( dir == -1 )) && return
314 if (( dir < 0 || dir >= i )); then
315 echo d: no such directory stack entry: $dir
321 # find out which libs define a symbol
322 # usage example: 'lcheck strcpy'
324 if [ -n "$1" ] ; then
325 nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
327 echo "Usage: lcheck <function>" >&2
333 FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
335 if [[ $NBFILES > 0 ]]; then
338 echo -n "Remove these files? [y/n] "
343 echo ">> $PWD purged, $NBFILES files removed"
345 echo "Ok. .. than not.."
351 # 'translate' looks up fot a word in a file with language-to-language
352 # translations (field separator should be " : "). A typical wordlist looks
354 # | english-word : german-transmission
355 # It's also only possible to translate english to german but not reciprocal.
356 # Use the following oneliner to turn back the sort order:
357 # $ awk -F ':' '{ print $2" : "$1" "$3 }' \
358 # /usr/local/lib/words/en-de.ISO-8859-1.vok > ~/.translate/de-en.ISO-8859-1.vok
361 -[dD]*) translate -l de-en $2
363 -[eE]*) translate -l en-de $2
366 echo "Usage: $0 { -D | -E }"
367 echo " -D == German to English"
368 echo " -E == English to German"
372 # Some quick Perl-hacks aka /useful/ oneliner
373 # bew() { perl -le 'print unpack "B*","'$1'"' }
374 # web() { perl -le 'print pack "B*","'$1'"' }
375 # hew() { perl -le 'print unpack "H*","'$1'"' }
376 # weh() { perl -le 'print pack "H*","'$1'"' }
377 # pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
378 # getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
379 # gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
380 # getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
381 # getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
382 # getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
383 # getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
384 # showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
385 # vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
386 # vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
388 # plap foo -- list all occurrences of program in the current PATH
392 echo "Usage: $0 program"
393 echo "Example: $0 zsh"
394 echo "Lists all occurrences of program in the current PATH."
396 ls -l ${^path}/*$1*(*N)
400 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
405 echo "Usage: $0 command"
408 cmd=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
409 print -l $cmd | less -F
410 echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
413 print -z "${cmd[$answer]#*$TAB}"
416 # Use vim to convert plaintext to HTML
417 2html() { vim -u NONE -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 &>/dev/null }
419 # Usage: simple-extract <file>
420 # Description: extracts archived files (maybe)
425 *.tar.bz2) bzip2 -v -d $1 ;;
426 *.tar.gz) tar -xvzf $1 ;;
429 *.bz2) bzip2 -d $1 ;;
431 *.gz) gunzip -d $1 ;;
432 *.tar) tar -xvf $1 ;;
433 *.tgz) gunzip -d $1 ;;
434 *.tbz2) tar -jxvf $1 ;;
436 *.Z) uncompress $1 ;;
437 *) echo "'$1' Error. Please go away" ;;
440 echo "'$1' is not a valid file"
444 # Usage: smartcompress <file> (<type>)
445 # Description: compresses files or a directory. Defaults to tar.gz
449 tgz | tar.gz) tar -zcvf$1.$2 $1 ;;
450 tbz2 | tar.bz2) tar -jcvf$1.$2 $1 ;;
451 tar.Z) tar -Zcvf$1.$2 $1 ;;
452 tar) tar -cvf$1.$2 $1 ;;
453 gz | gzip) gzip $1 ;;
454 bz2 | bzip2) bzip2 $1 ;;
456 echo "Error: $2 is not a valid compression type"
460 smartcompress $1 tar.gz
464 # Usage: show-archive <archive>
465 # Description: view archive without unpack
470 *.tar.gz) gunzip -c $1 | tar -tf - -- ;;
472 *.tgz) tar -ztf $1 ;;
473 *.zip) unzip -l $1 ;;
475 *) echo "'$1' Error. Please go away" ;;
478 echo "'$1' is not a valid archive"
484 if [[ -e $1 || -h $1 ]]; then
489 if [[ -e $file || -L $file ]]; then
490 if [[ -L $file ]]; then
491 echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
492 folsym `perl -le '$file = $ARGV[0];
493 $dest = readlink $file;
494 if ($dest !~ m{^/}) {
495 $file =~ s{(/?)[^/]*$}{$1$dest};
499 $file =~ s{/{2,}}{/}g;
500 while ($file =~ s{[^/]+/\.\./}{}) {
503 $file =~ s{^(/\.\.)+}{};
513 # Use 'view' to read manpages, if u want colors, regex - search, ...
515 # It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
516 vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
518 # search for various types or README file in dir and display them in $PAGER
519 # function readme() { $PAGER -- (#ia3)readme* }
522 files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
526 print 'No README files.'
530 # find all suid files in $PATH
531 # suidfind() { ls -latg $path | grep '^...s' }
532 suidfind() { ls -latg $path/*(sN) }
534 # See above but this is /better/ ... anywise ..
536 print 'Output will be written to ~/suid_* ...'
537 $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
538 $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
539 $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
540 $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
553 # a small check to see which DIR is located on which server/partition.
554 # stolen and modified from Sven's zshrc.forall
556 if [ -n "$1" ] ; then
558 if [ -d "$dir" ] ; then
559 ( cd $dir; echo "-<$dir>"; du -shx .; echo);
561 echo "warning: $dir does not exist" >&2
566 if [ -d "$dir" ] ; then
567 ( cd $dir; echo "-<$dir>"; du -shx .; echo);
569 echo "warning: $dir does not exist" >&2
575 # % slow_print `cat /etc/passwd`
577 for argument in "${@}"
579 for ((i = 1; i <= ${#1} ;i++)) {
580 print -n "${argument[i]}"
588 # display system state
591 print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
592 print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
593 print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
594 print "Login.: $LOGNAME (UID = $EUID) on $HOST"
595 print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
596 print "Uptime:$(uptime)"
604 cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
605 cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
606 echo " * Would you like to burn the cd now? (yes/no)"
609 [ "$input" = "yes" ]; then
610 echo " ! Burning Audio CD"
614 echo " ! Invalid response."
621 cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
622 echo " * Should I remove the temporary files? (yes/no)"
624 if [ "$input" = "yes" ]; then
625 echo " ! Removing Temporary Files."
630 echo " ! Invalid response."
634 # Make an audio CD from all mp3 files
637 for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
638 for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
639 for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
641 for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
644 # Create an ISO image. You are prompted for volume name, filename and directory
646 echo " * Volume name "
648 echo " * ISO Name (ie. tmp.iso)"
650 echo " * Directory or File"
652 mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
655 # simple thumbnails generator
657 rm -rf thumb-* index.html
661 <title>Images</title>
664 for f in *.(gif|jpeg|jpg|png)
666 convert -size 100x200 "$f" -resize 100x200 thumb-"$f"
667 echo " <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
671 </html>" >> index.html
674 # unset all limits (see zshbuiltins(1) /ulimit for details)
685 # ogg2mp3 with bitrate of 192
687 oggdec -o - ${1} | lame -b 192 - ${1:r}.mp3
690 # RFC 2396 URL encoding in Z-Shell
692 setopt localoptions extendedglob
694 print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
697 # get x-lite voip software
701 [ -d ~/tmp ] || mkdir ~/tmp
703 echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
704 if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
705 unp X-Lite_Install.tar.gz && echo done || echo failed
707 echo "Error while downloading." ; return 1
709 if [ -x xten-xlite/xtensoftphone ] ; then
710 echo "Execute xten-xlite/xtensoftphone to start xlite."
718 echo "Downloading debian package of skype."
719 echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
720 wget http://www.skype.com/go/getskype-linux-deb
721 $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
724 # get beta-version of skype
728 echo "Downloading debian package of skype (beta version)."
729 wget http://www.skype.com/go/getskype-linux-beta-deb
730 $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
733 # get gzimo (VoIP software)
737 echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
739 $SUDO apt-get install gconf2-common libgconf2-4
740 wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
741 $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
744 # get AIR - Automated Image and Restore
748 [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
750 wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
751 tar zxf air-$VER.tar.gz
753 INTERACTIVE=no $SUDO ./install-air-1.2.8
754 [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
757 # get specific git commitdiff
759 if [ -z $GITTREE ] ; then
760 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
762 if ! [ -z $1 ] ; then
763 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commitdiff;h=$1"
765 echo "Usage: git-get-diff <commit>"
769 # get specific git commit
771 if [ -z $GITTREE ] ; then
772 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
774 if ! [ -z $1 ] ; then
775 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commit;h=$1"
777 echo "Usage: git-get-commit <commit>"
781 # get specific git diff
782 git-get-plaindiff() {
783 if [ -z $GITTREE ] ; then
784 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
786 if ! [ -z $1 ] ; then
787 wget "http://kernel.org/git/?p=$GITTREE;a=commitdiff_plain;h=$1" -O $1.diff
789 echo 'Usage: git-get-plaindiff '
793 # log 'make install' output
794 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
796 [[ ! -d ~/.errorlogs ]] && mkdir ~/.errorlogs
797 =make -n install > ~/.errorlogs/${PWD##*/}-makelog
802 indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs $*
805 # highlight important stuff in diff output, usage example: hg diff | hidiff
806 [ -x $(which histring) ] && \
807 alias hidiff="histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'"
809 # rename pictures based on information found in exif headers
811 if [ $# -lt 1 ] ; then
812 echo 'Usage: jpgrename $FILES' >& 2
815 echo -n 'Checking for jhead with version newer than 1.9: '
816 jhead_version=`jhead -h | grep 'used by most Digital Cameras. v.*' | awk '{print $6}' | tr -d v`
817 if [[ $jhead_version > '1.9' ]]; then
818 echo 'success - now running jhead.'
819 jhead -n%Y-%m-%d_%Hh%M_%f $*
821 echo 'failed - exiting.'
826 # open file in vim and jump to line
827 # http://www.downgra.de/archives/2007/05/08/T19_21_11/
830 params=(${*//(#m):[0-9]*:/\\n+${MATCH//:/}}) # replace ':23:' to '\n+23'
831 params=(${(s|\n|)${(j|\n|)params}}) # join array using '\n', then split on all '\n'
835 # get_ic() - queries imap servers for capabilities; real simple. no imaps
838 if [[ ! -z $1 ]]; then
840 print "querying imap server on $1:${port}...\n";
841 print "a1 capability\na2 logout\n" | nc $1 ${port}
843 print "usage:\n $0 <imap-server> [port]"
847 # creates a Maildir/ with its {new,cur,tmp} subdirs
850 root=${MAILDIR_ROOT:-${HOME}/Mail}
851 if [[ -z ${1} ]] ; then print "Usage\n $0 <dirname>" ; fi
853 mkdir -p ${root}/${subdir}/{cur,new,tmp}
856 # xtrename() rename xterm from within GNU-screen
858 if [[ -z ${DISPLAY} ]] ; then
859 printf 'xtrename only makes sense in X11.\n'
862 if [[ -z ${1} ]] ; then
863 printf 'usage: xtrename() "title for xterm"\n'
864 printf ' renames the title of xterm from _within_ screen.\n'
865 printf ' Also works without screen.\n'
868 print -n "\eP\e]0;${1}\C-G\e\\"
872 # hl() highlighted less
873 # http://ft.bewatermyfriend.org/comp/data/zsh/zfunct.html
874 if [ -x $(which highlight) ] ; then
877 theme=${HL_THEME:-""}
880 ( printf 'available languages (syntax parameter):\n\n' ;
881 highlight --list-langs ; ) | less -SMr
884 ( printf 'available themes (style parameter):\n\n' ;
885 highlight --list-themes ; ) | less -SMr
888 printf 'usage: hl <syntax[:theme]> <file>\n'
889 printf ' available options: --list (-l), --themes (-t), --help (-h)\n\n'
890 printf ' Example: hl c main.c\n'
893 if [[ -z ${2} ]] || (( ${#argv} > 2 )) ; then
894 printf 'usage: hl <syntax[:theme]> <file>\n'
895 printf ' available options: --list (-l), --themes (-t), --help (-h)\n'
896 (( ${#argv} > 2 )) && printf ' Too many arguments.\n'
900 [[ ${1} == *:* ]] && [[ -n ${1#*:} ]] && theme=${1#*:}
901 if [[ -n ${theme} ]] ; then
902 highlight --xterm256 --syntax ${lang} --style ${theme} ${2} | less -SMr
904 highlight --ansi --syntax ${lang} ${2} | less -SMr
910 # ... and a proper completion for hl()
911 # needs 'highlight' as well, so it fits fine in here.
912 function _hl_genarg() {
914 if [[ -prefix 1 *: ]] ; then
916 themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*})
918 _wanted -C list themes expl theme compadd ${themes}
921 langs=(${${${(f)"$(LC_ALL=C highlight --list-langs)"}/ #/}:#*(Installed|Use name)*})
922 _wanted -C list languages expl languages compadd -S ':' -q ${langs}
925 function _hl_complete() {
926 _arguments -s '1: :_hl_genarg' '2:files:_path_files'
928 compdef _hl_complete hl
931 # create small urls via tinyurl.com using wget, grep and sed
933 [[ -z ${1} ]] && print "please give an url to shrink." && return 1
935 local tiny="http://tinyurl.com/create.php?url="
936 #print "${tiny}${url}" ; return
940 | grep -Eio 'value="(http://tinyurl.com/.*)"' \
941 | sed 's/value=//;s/"//g'
944 # change fluxbox keys from 'Alt-#' to 'Alt-F#' and vice versa
946 [ -n "$FLUXKEYS" ] || local FLUXKEYS="$HOME/.fluxbox/keys"
947 if ! [ -r "$FLUXKEYS" ] ; then
948 echo "Sorry, \$FLUXKEYS file $FLUXKEYS could not be read - nothing to be done."
951 if grep -q 'Mod1 F[0-9] :Workspace [0-9]' $FLUXKEYS ; then
952 echo -n 'Switching to Alt-# mode in ~/.fluxbox/keys: '
953 sed -i -e 's|^\(Mod[0-9]\+[: space :]\+\)F\([0-9]\+[: space :]\+:Workspace.*\)|\1\2|' $FLUXKEYS && echo done || echo failed
954 elif grep -q 'Mod1 [0-9] :Workspace [0-9]' $FLUXKEYS ; then
955 echo -n 'Switching to Alt-F# mode in ~/.fluxbox/keys: '
956 sed -i -e 's|^\(Mod[0-9]\+[: space :]\+\)\([0-9]\+[: space :]\+:Workspace.*\)|\1F\2|' $FLUXKEYS && echo done || echo failed
958 echo 'Sorry, do not know what to do.'
966 # mercurial related stuff {{{
967 if type -p hg &>/dev/null ; then
968 # gnu like diff for mercurial
969 # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
971 for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
974 # build debian package
975 alias hbp='hg-buildpackage'
977 # execute commands on the versioned patch-queue from the current repos
978 alias mq='hg -R $(readlink -f $(hg root)/.hg/patches)'
980 # diffstat for specific version of a mercurial repository
981 # hgstat => display diffstat between last revision and tip
982 # hgstat 1234 => display diffstat between revision 1234 and tip
984 [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
987 # get current mercurial tip via hg itself
991 if [ -f mercurial-tree/.hg ] ; then
993 echo "Running hg pull for retreiving latest version..."
995 echo "Finished update. Building mercurial"
997 echo "Setting \$PATH to $PWD:\$PATH..."
998 export PATH="$PWD:$PATH"
1000 echo "Downloading mercurial via hg"
1001 hg clone http://selenic.com/repo/hg mercurial-tree
1003 echo "Building mercurial"
1005 echo "Setting \$PATH to $PWD:\$PATH..."
1006 export PATH="$PWD:$PATH"
1007 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
1008 # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
1009 # export PYTHONPATH=${HOME}/lib/python
1013 fi # end of check whether we have the 'hg'-executable
1015 # get current mercurial snapshot
1017 setopt local_options
1019 if [ -f mercurial-snapshot.tar.gz ] ; then
1020 echo "mercurial-snapshot.tar.gz exists already, skipping download."
1022 echo "Downloading mercurial snapshot"
1023 wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
1025 echo "Unpacking mercurial-snapshot.tar.gz"
1026 tar zxf mercurial-snapshot.tar.gz
1027 cd mercurial-snapshot/
1028 echo "Installing required build-dependencies"
1029 $SUDO apt-get update
1030 $SUDO apt-get install python2.4-dev
1031 echo "Building mercurial"
1033 echo "Setting \$PATH to $PWD:\$PATH..."
1034 export PATH="$PWD:$PATH"
1035 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
1039 # some useful commands often hard to remember - let's grep for them {{{
1041 # Work around ion/xterm resize bug.
1042 #if [ "$SHLVL" = 1 ]; then
1043 # if [ -x $(which resize) ]; then
1044 # eval `resize </dev/null`
1049 # /usr/bin/jackd -dalsa -dhw:0 -r48000 -p1024 -n2
1050 # now play audio file:
1051 # alsaplayer -o jack foobar.mp3
1053 # send files via netcat
1055 # send() {j=$*; tar cpz ${j/%${!#}/}|nc -w 1 ${!#} 51330;}
1057 # alias receive='nc -vlp 51330 | tar xzvp'
1060 # dh_make -e foo@localhost -f $1
1061 # dpkg-buildpackage -rfakeroot
1063 # dpkg-scanpackages ./ /dev/null | gzip > Packages.gz
1064 # dpkg-scansources . | gzip > Sources.gz
1065 # grep-dctrl --field Maintainer $* /var/lib/apt/lists/*
1068 # convert -geometry 200x200 -interlace LINE -verbose
1069 # ldapsearch -x -b "OU=Bedienstete,O=tug" -h ldap.tugraz.at sn=$1
1070 # ps -ao user,pcpu,start,command
1071 # gpg --keyserver blackhole.pca.dfn.de --recv-keys
1072 # xterm -bg black -fg yellow -fn -misc-fixed-medium-r-normal--14-140-75-75-c-90-iso8859-15 -ah
1073 # nc -vz $1 1-1024 # portscan via netcat
1074 # wget --mirror --no-parent --convert-links
1076 # autoload -U tetris; zle -N tetris; bindkey '...' ; echo "press ... for playing tennis"
1078 # modify console cursor
1079 # see http://www.tldp.org/HOWTO/Framebuffer-HOWTO-5.html
1080 # print $'\e[?96;0;64c'
1083 # finally source a local zshrc and grmlsmall-specific configuration {{{
1085 # The following file is used to remove zsh-config-items that do not work
1086 # in grml-small by default.
1087 # If you do not want these adjustments (for whatever reason),
1088 # there are three ways to accomplish that:
1089 # a) at the beginning of this file (variables section), set
1090 # $GRMLSMALL_SPECIFIC to 0 or comment out the variable definition.
1091 # b) remove/rename .zshrc.grmlsmall
1092 # c) comment out the following line
1093 (( GRMLSMALL_SPECIFIC > 0 )) && isgrmlsmall && source ~/.zshrc.grmlsmall
1095 # this allows us to stay in sync with /etc/skel/.zshrc
1096 # through 'ln -s /etc/skel/.zshrc ~/.zshrc' and put own
1097 # modifications in ~/.zshrc.local
1098 if [ -r ~/.zshrc.local ] ; then
1103 ## END OF FILE #################################################################
1104 # vim:foldmethod=marker