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 Okt 26 00:50:18 CEST 2006 [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 }
25 # set terminal property (used e.g. by msgid-chooser)
26 export COLORTERM="yes"
29 if [ -z $BROWSER ] ; then
30 if [ -n "$DISPLAY" ] ; then
31 [ -x =firefox ] && export BROWSER=firefox
33 [ -x =w3m ] && export BROWSER=w3m
36 (( ${+PAGER} )) || export PAGER="less"
39 [ -d /usr/share/qt3 ] && export QTDIR=/usr/share/qt3
40 [ -d /usr/share/qt4 ] && export QTDIR=/usr/share/qt4
42 # support running 'jikes *.java && jamvm HelloWorld' OOTB:
43 [ -f /usr/share/classpath/glibj.zip ] && export JIKESPATH=/usr/share/classpath/glibj.zip
48 # Allow comments even in interactive shells i. e.
49 # $ uname # This command prints system informations
51 # $ setopt interactivecomments
52 # $ uname # This command prints system informations
54 # setopt interactivecomments
56 # ctrl-s will no longer freeze the terminal.
62 # These do not have to be at the beginning of the command line.
63 # Avoid typing cd ../../ for going two dirs down and so on
64 # Usage, e.g.: "$ cd ...' or just '$ ...' with 'setopt auto_cd'
65 alias -g '...'='../..'
66 alias -g '....'='../../..'
67 # Usage is "$ somecommand C (this pipes it into 'wc -l'):
72 alias -g Hl=' --help |& less -r'
75 alias -g LL='|& less -r'
77 alias -g N='&>/dev/null'
78 alias -g R='| tr A-z N-za-m'
79 alias -g SL='| sort | less'
85 ## another approach for global aliases: cloning vim's abbreviation feature {{{
86 # http://zshwiki.org/home/examples/zleiab
87 # typeset -A abbreviations
94 # "Igr" "| groff -s -p -t -e -Tlatin1 -mandoc"
100 # "Iv" "| ${VISUAL:-${EDITOR}}"
105 # magic-abbrev-expand() {
107 # LBUFFER=${LBUFFER%%(#m)[_a-zA-Z0-9]#}
108 # LBUFFER+=${abbreviations[$MATCH]:-$MATCH}
112 # no-magic-abbrev-expand() {
116 # zle -N magic-abbrev-expand
117 # zle -N no-magic-abbrev-expand
118 # bindkey " " magic-abbrev-expand
119 # bindkey "^x " no-magic-abbrev-expand
125 # Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
126 alias hide='echo -en "\033]50;nil2\007"'
127 alias tiny='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-80-*-*-c-*-iso8859-15\007"'
128 alias small='echo -en "\033]50;6x10\007"'
129 alias medium='echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-15\007"'
130 alias default='echo -e "\033]50;-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-15\007"'
131 alias large='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-150-*-*-c-*-iso8859-15\007"'
132 alias huge='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-210-*-*-c-*-iso8859-15\007"'
133 alias smartfont='echo -en "\033]50;-artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*\007"'
134 alias semifont='echo -en "\033]50;-misc-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-15\007"'
135 # if [ "$TERM" = "xterm" ] && [ "$LINES" -ge 50 ] && [ "$COLUMNS" -ge 100 ] && [ -z "$SSH_CONNECTION" ]; then
142 # alias u='translate -i' # translate
145 alias CO="./configure"
146 alias CH="./configure --help"
148 # http://conkeror.mozdev.org/
149 alias conkeror='firefox -chrome chrome://conkeror/content'
152 alias ldiff='tla what-changed --diffs | less'
153 alias tbp='tla-buildpackage'
154 alias mirror='tla archive-mirror'
155 alias commit='tla commit'
156 alias merge='tla star-merge'
159 alias dir="ls -lSrah"
160 alias lad='ls -d .*(/)' # only show dot-directories
161 alias lsa='ls -a .*(.)' # only show dot-files
162 alias lss='ls -l *(s,S,t)' # only files with setgid/setuid/sticky flag
163 alias lsl='ls -l *(@[1,10])' # only symlinks
164 alias lsx='ls -l *(*[1,10])' # only executables
165 alias lsw='ls -ld *(R,W,X.^ND/)' # world-{readable,writable,executable} files
166 alias lsbig="ls -flh *(.OL[1,10])" # display the biggest files
167 alias lsd='ls -d *(/)' # only show directories
168 alias lse='ls -d *(/^F)' # only show empty directories
169 alias lsnew="ls -rl *(D.om[1,10])" # display the newest files
170 alias lsold="ls -rtlh *(D.om[1,10])" # display the oldest files
171 alias lssmall="ls -Srl *(.oL[1,10])" # display the smallest files
174 alias rw-='chmod 600'
175 alias rwx='chmod 700'
176 alias r--='chmod 644'
177 alias r-x='chmod 755'
179 # some useful aliases
183 alias cmplayer='mplayer -vo fbdev'
184 # alias fbmplayer='mplayer -vo fbdev'
185 alias fbmplayer='mplayer -vo fbdev -fs -zoom'
186 alias fblinks='links2 -driver fb'
188 # ignore ~/.ssh/known_hosts entries
189 # alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
190 alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
192 # use colors when browsing man pages (if not using pinfo or PAGER=most)
193 [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
195 # check whether Debian's package management (dpkg) is running
196 alias check_dpkg_running="$SUDO dpkg_running"
199 ## useful functions {{{
201 # functions without detailed explanation:
202 agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
203 bk() { cp -b ${1} ${1}_`date --iso-8601=m` }
204 cdiff() { diff -crd "$*" | egrep -v "^Only in |^Binary files " }
205 cl() { cd $1 && ls -a } # cd && ls
206 cvsa() { cvs add $* && cvs com -m 'initial checkin' $* }
207 cvsd() { cvs diff -N $* |& $PAGER }
208 cvsl() { cvs log $* |& $PAGER }
209 cvsq() { cvs -nq update }
210 cvsr() { rcs2log $* | $PAGER }
211 cvss() { cvs status -v $* }
212 debbug() { ${=BROWSER} "http://bugs.debian.org/$*" }
213 debbugm() { bts show --mbox $1 } # provide bugnummer as $1
214 disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null }
215 dmoz() { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
216 dwicti() { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }
217 ewicti() { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }
218 fir() { firefox -a firefox -remote "openURL($1)" }
219 ggogle() { ${=BROWSER} "http://groups.google.com/groups?q=$*" }
220 google() { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }
221 mdiff() { diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1" }
222 memusage(){ ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc }
223 mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }
224 netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }
225 oleo() { ${=BROWSER} "http://dict.leo.org/?search=$*" }
226 shtar() { gunzip -c $1 | tar -tf - -- | $PAGER }
227 shtgz() { tar -ztf $1 | $PAGER }
228 shzip() { unzip -l $1 | $PAGER }
229 sig() { agrep -d '^-- $' "$*" ~/.Signature }
230 swiki() { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }
231 udiff() { diff -urd $* | egrep -v "^Only in |^Binary files " }
232 viless() { vim --cmd 'let no_plugin_maps = 1' -c "so \$VIMRUNTIME/macros/less.vim" "${@:--}" }
233 wikide () { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }
234 wikien() { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
235 wodeb () { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
237 which google >/dev/null 2>&1 && gex () { google "\"[ $1]\" $*" } # exact search at google
239 # Function Usage: doc packagename
240 doc() { cd /usr/share/doc/$1 && ls }
241 _doc() { _files -W /usr/share/doc -/ }
248 $SUDO apt-get -u upgrade
250 ssh $1 $SUDO apt-get update
251 # ask before the upgrade
253 ssh $1 $SUDO apt-get --no-act upgrade
254 echo -n "Process the upgrade ?"
256 if [[ $dummy == "y" ]] ; then
257 ssh $1 $SUDO apt-get -u upgrade --yes
262 # make screenshot of current desktop (use 'import' from ImageMagic)
264 [[ ! -d ~/shots ]] && mkdir ~/shots
265 #cd ~/shots ; sleep 5 ; import -window root -depth 8 -quality 80 `date "+%Y-%m-%d--%H:%M:%S"`.png
266 cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg
273 images=( *.{jpg,gif,png}(.N) )
274 if [[ $#images -eq 0 ]] ; then
275 print "No image files found"
282 # create pdf file from source code
286 a2ps --medium A4dj -E -o $output $*
290 # zsh with perl-regex - use it e.g. via:
291 # regcheck '\s\d\.\d{3}\.\d{3} Euro' ' 1.000.000 Euro'
295 pcre_match $2 && echo "regex matches" || echo "regex does not match"
297 # list files which have been modified within the last x days
298 new() { print -l *(m-$1) }
301 greph () { history 0 | grep $1 }
302 (grep --help 2>/dev/null |grep -- --color) >/dev/null && \
303 alias grep='grep --color=auto' # use colors when GNU grep with color-support
304 alias GREP='grep -i --color=auto'
306 # one blank line between each line
307 if [ -r ~/.terminfo/m/mostlike ] ; then
308 # alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
309 man2() { PAGER='dash -c "sed G | /usr/bin/less"' TERM=mostlike /usr/bin/man "$@" ; }
312 # jump between directories
313 # Copyright 2005 Nikolai Weibull <nikolai@bitwi.se>
314 # notice: option AUTO_PUSHD has to be set
318 local color=$fg_bold[blue]
320 dirs -p | while read dir; do
321 local num="${$(printf "%-4d " $i)/ /.}"
322 printf " %s $color%s$reset_color\n" $num $dir
326 read -r 'dir?Jump to directory: ' || return
327 (( dir == -1 )) && return
328 if (( dir < 0 || dir >= i )); then
329 echo d: no such directory stack entry: $dir
335 # provide useful information on globbing
342 p named pipes (FIFOs)
343 * executable plain files (0100)
344 % device files (character or block special)
345 %b block special files
346 %c character special files
347 r owner-readable files (0400)
348 w owner-writable files (0200)
349 x owner-executable files (0100)
350 A group-readable files (0040)
351 I group-writable files (0020)
352 E group-executable files (0010)
353 R world-readable files (0004)
354 W world-writable files (0002)
355 X world-executable files (0001)
356 s setuid files (04000)
357 S setgid files (02000)
358 t files with the sticky bit (01000)
359 print *(m-1) # Dateien, die vor bis zu einem Tag modifiziert wurden.
360 print *(a1) # Dateien, auf die vor einem Tag zugegriffen wurde.
361 print *(@) # Nur Links
362 print *(Lk+50) # Dateien die ueber 50 Kilobytes grosz sind
363 print *(Lk-50) # Dateien die kleiner als 50 Kilobytes sind
364 print **/*.c # Alle *.c - Dateien unterhalb von \$PWD
365 print **/*.c~file.c # Alle *.c - Dateien, aber nicht 'file.c'
366 print (foo|bar).* # Alle Dateien mit 'foo' und / oder 'bar' am Anfang
367 print *~*.* # Nur Dateien ohne '.' in Namen
368 chmod 644 *(.^x) # make all non-executable files publically readable
369 print -l *(.c|.h) # Nur Dateien mit dem Suffix '.c' und / oder '.h'
370 print **/*(g:users:) # Alle Dateien/Verzeichnisse der Gruppe >users<
371 echo /proc/*/cwd(:h:t:s/self//) # Analog zu >ps ax | awk '{print $1}'<"
375 nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"":[[:xdigit:]]\{8\} . .*$1"
380 FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
382 if [[ $NBFILES > 0 ]]; then
385 echo -n "Remove these files? [y/n] "
390 echo ">> $PWD purged, $NBFILES files removed"
392 echo "Ok. .. than not.."
398 # 'translate' looks up fot a word in a file with language-to-language
399 # translations (field separator should be " : "). A typical wordlist looks
401 # | english-word : german-transmission
402 # It's also only possible to translate english to german but not reciprocal.
403 # Use the following oneliner to turn back the sort order:
404 # $ awk -F ':' '{ print $2" : "$1" "$3 }' \
405 # /usr/local/lib/words/en-de.ISO-8859-1.vok > ~/.translate/de-en.ISO-8859-1.vok
408 -[dD]*) translate -l de-en $2
410 -[eE]*) translate -l en-de $2
413 echo "Usage: $0 { -D | -E }"
414 echo " -D == German to English"
415 echo " -E == English to German"
419 # Some quick Perl-hacks aka /useful/ oneliner
420 # bew() { perl -le 'print unpack "B*","'$1'"' }
421 # web() { perl -le 'print pack "B*","'$1'"' }
422 # hew() { perl -le 'print unpack "H*","'$1'"' }
423 # weh() { perl -le 'print pack "H*","'$1'"' }
424 # pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
425 # getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
426 # gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
427 # getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
428 # getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
429 # getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
430 # getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
431 # showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
432 # vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
433 # vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
435 # plap foo -- list all occurrences of program in the current PATH
439 echo "Usage: $0 program"
440 echo "Example: $0 zsh"
441 echo "Lists all occurrences of program in the current PATH."
443 ls -l ${^path}/*$1*(*N)
447 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
452 echo "Usage: $0 command"
455 cmd=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
456 print -l $cmd | less -F
457 echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
460 print -z "${cmd[$answer]#*$TAB}"
464 mcd() { mkdir -p "$@"; cd "$@" } # mkdir && cd
467 cl() { cd $1 && ls -a }
469 # Use vim to convert plaintext to HTML
470 2html() { vim -u NONE -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 > /dev/null 2> /dev/null }
472 # Usage: simple-extract <file>
473 # Description: extracts archived files (maybe)
478 *.tar.bz2) bzip2 -v -d $1 ;;
479 *.tar.gz) tar -xvzf $1 ;;
482 *.bz2) bzip2 -d $1 ;;
484 *.gz) gunzip -d $1 ;;
485 *.tar) tar -xvf $1 ;;
486 *.tgz) gunzip -d $1 ;;
487 *.tbz2) tar -jxvf $1 ;;
489 *.Z) uncompress $1 ;;
490 *) echo "'$1' Error. Please go away" ;;
493 echo "'$1' is not a valid file"
497 # Usage: smartcompress <file> (<type>)
498 # Description: compresses files or a directory. Defaults to tar.gz
502 tgz | tar.gz) tar -zcvf$1.$2 $1 ;;
503 tbz2 | tar.bz2) tar -jcvf$1.$2 $1 ;;
504 tar.Z) tar -Zcvf$1.$2 $1 ;;
505 tar) tar -cvf$1.$2 $1 ;;
506 gz | gzip) gzip $1 ;;
507 bz2 | bzip2) bzip2 $1 ;;
509 echo "Error: $2 is not a valid compression type"
513 smartcompress $1 tar.gz
517 # Usage: show-archive <archive>
518 # Description: view archive without unpack
523 *.tar.gz) gunzip -c $1 | tar -tf - -- ;;
525 *.tgz) tar -ztf $1 ;;
526 *.zip) unzip -l $1 ;;
528 *) echo "'$1' Error. Please go away" ;;
531 echo "'$1' is not a valid archive"
536 if [[ -e $1 || -h $1 ]]; then
541 if [[ -e $file || -L $file ]]; then
542 if [[ -L $file ]]; then
543 echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
544 folsym `perl -le '$file = $ARGV[0];
545 $dest = readlink $file;
546 if ($dest !~ m{^/}) {
547 $file =~ s{(/?)[^/]*$}{$1$dest};
551 $file =~ s{/{2,}}{/}g;
552 while ($file =~ s{[^/]+/\.\./}{}) {
555 $file =~ s{^(/\.\.)+}{};
565 # Use 'view' to read manpages, if u want colors, regex - search, ...
567 # It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
568 vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
570 # search for various types or README file in dir and display them in $PAGER
571 # function readme() { $PAGER -- (#ia3)readme* }
574 files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
578 print 'No README files.'
582 # find all suid files in $PATH
583 # suidfind() { ls -latg $path | grep '^...s' }
584 suidfind() { ls -latg $path/*(sN) }
586 # See above but this is /better/ ... anywise ..
588 print 'Output will be written to ~/suid_* ...'
589 $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
590 $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
591 $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
592 $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
605 # a small check to see which DIR is located on which server/partition.
606 # stolen and modified from Sven's zshrc.forall
610 (cd $dir; echo "-<$dir>"; du -shx .; echo);
614 # $ show_print `cat /etc/passwd`
616 for argument in "${@}"
618 for ((i = 1; i <= ${#1} ;i++)) {
619 print -n "${argument[i]}"
629 print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
630 print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
631 print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
632 print "Login.: $LOGNAME (UID = $EUID) on $HOST"
633 print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
634 print "Uptime:$(uptime)"
641 cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
642 cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
643 echo " * Would you like to burn the cd now? (yes/no)"
646 [ "$input" = "yes" ]; then
647 echo " ! Burning Audio CD"
651 echo " ! Invalid response."
657 cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
658 echo " * Should I remove the temporary files? (yes/no)"
660 if [ "$input" = "yes" ]; then
661 echo " ! Removing Temporary Files."
666 echo " ! Invalid response."
672 for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
673 for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
674 for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
676 for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
680 echo " * Volume name "
682 echo " * ISO Name (ie. tmp.iso)"
684 echo " * Directory or File"
686 mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
689 # generate thumbnails ;)
691 rm -rf thumb-* index.html
695 <title>Images</title>
698 for f in *.(gif|jpeg|jpg|png)
700 convert -size 100x200 "$f" -resize 100x200 thumb-"$f"
701 echo " <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
705 </html>" >> index.html
708 # unset all limits (see zshbuiltins(1) /ulimit for details)
719 # ogg2mp3 with bitrate of 192
721 oggdec -o - ${1} | lame -b 192 - ${1:r}.mp3
724 # RFC 2396 URL encoding in Z-Shell
726 setopt localoptions extendedglob
728 print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
731 # get x-lite voip software
735 [ -d ~/tmp ] || mkdir ~/tmp
737 echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
738 if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
739 unp X-Lite_Install.tar.gz && echo done || echo failed
741 echo "Error while downloading." ; return 1
743 if [ -x xten-xlite/xtensoftphone ] ; then
744 echo "Execute xten-xlite/xtensoftphone to start xlite."
752 echo "Downloading debian package of skype."
753 echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
754 wget http://www.skype.com/go/getskype-linux-deb
755 $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
758 # get beta-version of skype
762 echo "Downloading debian package of skype (beta version)."
763 wget http://www.skype.com/go/getskype-linux-beta-deb
764 $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
767 # get gzimo (voicp software)
771 echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
773 $SUDO apt-get install gconf2-common libgconf2-4
774 wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
775 $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
778 # get AIR - Automated Image and Restore
782 [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
784 wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
785 tar zxf air-$VER.tar.gz
787 INTERACTIVE=no $SUDO ./install-air-1.2.8
788 [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
791 # get specific git commitdiff
793 if [ -z $GITTREE ] ; then
794 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
796 if ! [ -z $1 ] ; then
797 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commitdiff;h=$1"
799 echo "Usage: git-get-diff <commit>"
803 # get specific git commit
805 if [ -z $GITTREE ] ; then
806 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
808 if ! [ -z $1 ] ; then
809 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commit;h=$1"
811 echo "Usage: git-get-commit <commit>"
815 # get specific git diff
816 git-get-plaindiff() {
817 if [ -z $GITTREE ] ; then
818 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
820 if ! [ -z $1 ] ; then
821 wget "http://kernel.org/git/?p=$GITTREE;a=commitdiff_plain;h=$1" -O $1.diff
823 echo 'Usage: git-get-plaindiff '
827 # log 'make install' output
828 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
830 [[ ! -d ~/.errorlogs ]] && mkdir ~/.errorlogs
831 =make -n install > ~/.errorlogs/${PWD##*/}-makelog
836 indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs $*
840 # rename pictures based on information found in exif headers
842 if [ $# -lt 1 ] ; then
843 echo 'Usage: jpgrename $FILES' >& 2
846 echo -n 'Checking for jhead with version newer than 1.9: '
847 jhead_version=`jhead -h | grep 'used by most Digital Cameras. v.*' | awk '{print $6}' | tr -d v`
848 if [[ $jhead_version > '1.9' ]]; then
849 echo 'success - now running jhead.'
850 jhead -n%Y-%m-%d_%Hh%M_%f $*
852 echo 'failed - exiting.'
858 # mercurial related stuff {{{
859 if type -p hg >/dev/null 2>&1 ; then
860 # gnu like diff for mercurial
861 # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
863 for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
866 # diffstat for specific version of mercurial
867 # hgstat => display diffstat between last revision and tip
868 # hgstat 1234 => display diffstat between revision 1234 and tip
870 [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
873 # get current mercurial tip via hg itself and install it in $HOME
877 if [ -f mercurial-tree/.hg ] ; then
879 echo "Running hg pull for retreiving latest version..."
881 echo "Finished update. Building mercurial"
883 echo "Setting \$PATH to $PWD:\$PATH..."
884 export PATH="$PWD:$PATH"
886 echo "Downloading mercurial via hg"
887 hg clone http://selenic.com/repo/hg mercurial-tree
889 echo "Building mercurial"
891 echo "Setting \$PATH to $PWD:\$PATH..."
892 export PATH="$PWD:$PATH"
893 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
894 # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
895 # export PYTHONPATH=${HOME}/lib/python
899 fi # end of check whether we have the 'hg'-executable
901 # get and install current mercurial snapshot in $HOME
905 if [ -f mercurial-snapshot.tar.gz ] ; then
906 echo "mercurial-snapshot.tar.gz exists already, skipping download."
908 echo "Downloading mercurial snapshot"
909 wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
911 echo "Unpacking mercurial-snapshot.tar.gz"
912 tar zxf mercurial-snapshot.tar.gz
913 cd mercurial-snapshot/
914 echo "Installing required build-dependencies"
916 $SUDO apt-get install python2.4-dev
917 echo "Building mercurial"
919 echo "Setting \$PATH to $PWD:\$PATH..."
920 export PATH="$PWD:$PATH"
921 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
925 # some useful commands often hard to remember - let's grep for them {{{
927 # Work around ion/xterm resize bug.
928 #if [ "$SHLVL" = 1 ]; then
929 # if [ -x `which resize 2>/dev/null` ]; then
930 # eval `resize </dev/null`
935 # /usr/bin/jackd -dalsa -dhw:0 -r48000 -p1024 -n2
936 # now play audio file:
937 # alsaplayer -o jack foobar.mp3
939 # send files via netcat
941 # send() {j=$*; tar cpz ${j/%${!#}/}|nc -w 1 ${!#} 51330;}
943 # alias receive='nc -vlp 51330 | tar xzvp'
946 # dh_make -e foo@localhost -f $1
947 # dpkg-buildpackage -rfakeroot
949 # dpkg-scanpackages ./ /dev/null | gzip > Packages.gz
950 # dpkg-scansources . | gzip > Sources.gz
951 # grep-dctrl --field Maintainer $* /var/lib/apt/lists/*
954 # convert -geometry 200x200 -interlace LINE -verbose
955 # ldapsearch -x -b "OU=Bedienstete,O=tug" -h ldap.tugraz.at sn=$1
956 # ps -ao user,pcpu,start,command
957 # gpg --keyserver blackhole.pca.dfn.de --recv-keys
958 # xterm -bg black -fg yellow -fn -misc-fixed-medium-r-normal--14-140-75-75-c-90-iso8859-15 -ah
959 # nc -vz $1 1-1024 # portscan via netcat
960 # wget --mirror --no-parent --convert-links
962 # autoload -U tetris; zle -N tetris; bindkey '...' ; echo "press ... for playing tennis"
964 # modify console cursor
965 # see http://www.tldp.org/HOWTO/Framebuffer-HOWTO-5.html
966 # print $'\e[?96;0;64c'
969 # finally source a local zshrc {{{
970 # this allows us to stay in sync with /etc/skel/.zshrc
971 # through 'ln -s /etc/skel/.zshrc ~/.zshrc' and put own
972 # modifications in ~/.zshrc.local
973 if [ -r ~/.zshrc.local ] ; then
978 ## END OF FILE #################################################################
979 # vim:foldmethod=marker