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 Nov 24 23:08:52 CET 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 }
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 =firefox ] && export BROWSER=firefox
40 [ -x =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, use another approach - see 'power completion'
73 # alias -g '...'='../..'
74 # alias -g '....'='../../..'
75 # alias -g BG='& exit'
79 # alias -g Hl=' --help |& less -r'
82 # alias -g LL='|& less -r'
84 # alias -g N='&>/dev/null'
85 # alias -g R='| tr A-z N-za-m'
86 # alias -g SL='| sort | less'
89 # alias -g V='| vim -'
91 # power completion, see http://zshwiki.org/home/examples/zleiab
92 # less risky than the global aliases but powerful as well
93 # just type the abbreviation key and afterwards ',.' to expand it
96 setopt interactivecomments
104 'G' '|& grep --color=auto'
106 'Hl' ' --help |& less -r'
111 'R' '| tr A-z N-za-m'
116 'hide' "echo -en '\033]50;nil2\007'"
117 'tiny' 'echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-80-*-*-c-*-iso8859-15\007"'
118 'small' 'echo -en "\033]50;6x10\007"'
119 'medium' 'echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-15\007"'
120 'default' 'echo -e "\033]50;-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-15\007"'
121 'large' 'echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-150-*-*-c-*-iso8859-15\007"'
122 'huge' 'echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-210-*-*-c-*-iso8859-15\007"'
123 'smartfont' 'echo -en "\033]50;-artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*\007"'
124 'semifont' 'echo -en "\033]50;-misc-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-15\007"'
128 'co' "./configure && make && sudo make install"
129 'CH' "./configure --help"
130 'conkeror' 'firefox -chrome chrome://conkeror/content'
132 'lad' $'ls -d .*(/)\n# only show dot-directories'
133 'lsa' $'ls -a .*(.)\n# only show dot-files'
134 'lss' $'ls -l *(s,S,t)\n# only files with setgid/setuid/sticky flag'
135 'lsl' $'ls -l *(@[1,10])\n# only symlinks'
136 'lsx' $'ls -l *(*[1,10])\n# only executables'
137 'lsw' $'ls -ld *(R,W,X.^ND/)\n# world-{readable,writable,executable} files'
138 'lsbig' $'ls -flh *(.OL[1,10])\n# display the biggest files'
139 'lsd' $'ls -d *(/)\n# only show directories'
140 'lse' $'ls -d *(/^F)\n# only show empty directories'
141 'lsnew' $'ls -rl *(D.om[1,10])\n# display the newest files'
142 'lsold' $'ls -rtlh *(D.om[-11,-1])\n # display the oldest files'
143 'lssmall' $'ls -Srl *(.oL[1,10])\n# display the smallest files'
145 '600' 'chmod u+rw-x,g-rwx,o-rwx'
147 '700' 'chmod u+rwx,g-rwx,o-rwx'
148 'r--' 'chmod u+r-wx,g-rwx,o-rwx'
149 '644' $'chmod u+rw-x,g+r-wx,o+r-wx\n # 4=r,2=w,1=x'
150 '755' 'chmod u+rwx,g+r-w+x,o+r-w+x'
152 'cmplayer' 'mplayer -vo -fs -zoom fbdev'
153 'fbmplayer' 'mplayer -vo -fs -zoom fbdev'
154 'fblinks' 'links2 -driver fb'
155 'insecssh' 'ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
156 'fori' 'for i ({..}) { }'
159 'se' 'setopt interactivecomments'
160 'va' 'valac --vapidir=../vapi/ --pkg=gtk+-2.0 gtktest.vala'
161 'fb2' '=mplayer -vo fbdev -fs -zoom 1>/dev/null -xy 2'
162 'fb3' '=mplayer -vo fbdev -fs -zoom 1>/dev/null -xy 3'
164 'D' 'export DISPLAY=:0.0'
165 'mp' 'mplayer -vo xv -fs -zoom'
169 matched_chars='[.-|_a-zA-Z0-9]#'
170 LBUFFER=${LBUFFER%%(#m)[.-|_a-zA-Z0-9]#}
171 LBUFFER+=${abk[$MATCH]:-$MATCH}
174 bindkey ",." globalias
180 # Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
181 alias hide='echo -en "\033]50;nil2\007"'
182 alias tiny='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-80-*-*-c-*-iso8859-15\007"'
183 alias small='echo -en "\033]50;6x10\007"'
184 alias medium='echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-15\007"'
185 alias default='echo -e "\033]50;-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-15\007"'
186 alias large='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-150-*-*-c-*-iso8859-15\007"'
187 alias huge='echo -en "\033]50;-misc-fixed-medium-r-normal-*-*-210-*-*-c-*-iso8859-15\007"'
188 alias smartfont='echo -en "\033]50;-artwiz-smoothansi-*-*-*-*-*-*-*-*-*-*-*-*\007"'
189 alias semifont='echo -en "\033]50;-misc-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-15\007"'
190 # if [ "$TERM" = "xterm" ] && [ "$LINES" -ge 50 ] && [ "$COLUMNS" -ge 100 ] && [ -z "$SSH_CONNECTION" ]; then
197 # alias u='translate -i' # translate
200 alias CO="./configure"
201 alias CH="./configure --help"
203 # http://conkeror.mozdev.org/
204 alias conkeror='firefox -chrome chrome://conkeror/content'
207 if type -p tla >/dev/null 2>&1 ; then
208 alias tdi='tla what-changed --diffs | less'
209 alias tbp='tla-buildpackage'
210 alias tmi='tla archive-mirror'
211 alias tco='tla commit'
212 alias tme='tla star-merge'
216 alias dir="ls -lSrah"
217 alias lad='ls -d .*(/)' # only show dot-directories
218 alias lsa='ls -a .*(.)' # only show dot-files
219 alias lss='ls -l *(s,S,t)' # only files with setgid/setuid/sticky flag
220 alias lsl='ls -l *(@[1,10])' # only symlinks
221 alias lsx='ls -l *(*[1,10])' # only executables
222 alias lsw='ls -ld *(R,W,X.^ND/)' # world-{readable,writable,executable} files
223 alias lsbig="ls -flh *(.OL[1,10])" # display the biggest files
224 alias lsd='ls -d *(/)' # only show directories
225 alias lse='ls -d *(/^F)' # only show empty directories
226 alias lsnew="ls -rl *(D.om[1,10])" # display the newest files
227 alias lsold="ls -rtlh *(D.om[1,10])" # display the oldest files
228 alias lssmall="ls -Srl *(.oL[1,10])" # display the smallest files
231 alias rw-='chmod 600'
232 alias rwx='chmod 700'
233 alias r--='chmod 644'
234 alias r-x='chmod 755'
236 # some useful aliases
240 alias cmplayer='mplayer -vo fbdev'
241 # alias fbmplayer='mplayer -vo fbdev'
242 alias fbmplayer='mplayer -vo fbdev -fs -zoom'
243 alias fblinks='links2 -driver fb'
245 # ignore ~/.ssh/known_hosts entries
246 # alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
247 alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
249 # use colors when browsing man pages (if not using pinfo or PAGER=most)
250 [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
252 # check whether Debian's package management (dpkg) is running
253 alias check_dpkg_running="$SUDO dpkg_running"
256 ## useful functions {{{
258 # functions without detailed explanation:
259 agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
260 bk() { cp -b ${1} ${1}_`date --iso-8601=m` }
261 cdiff() { diff -crd "$*" | egrep -v "^Only in |^Binary files " }
262 cl() { cd $1 && ls -a } # cd && ls
263 cvsa() { cvs add $* && cvs com -m 'initial checkin' $* }
264 cvsd() { cvs diff -N $* |& $PAGER }
265 cvsl() { cvs log $* |& $PAGER }
266 cvsq() { cvs -nq update }
267 cvsr() { rcs2log $* | $PAGER }
268 cvss() { cvs status -v $* }
269 debbug() { ${=BROWSER} "http://bugs.debian.org/$*" }
270 debbugm() { bts show --mbox $1 } # provide bugnummer as $1
271 disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null }
272 dmoz() { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
273 dwicti() { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }
274 ewicti() { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }
275 fir() { firefox -a firefox -remote "openURL($1)" }
276 ggogle() { ${=BROWSER} "http://groups.google.com/groups?q=$*" }
277 google() { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }
278 mdiff() { diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1" }
279 memusage(){ ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc }
280 mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }
281 netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }
282 oleo() { ${=BROWSER} "http://dict.leo.org/?search=$*" }
283 shtar() { gunzip -c $1 | tar -tf - -- | $PAGER }
284 shtgz() { tar -ztf $1 | $PAGER }
285 shzip() { unzip -l $1 | $PAGER }
286 sig() { agrep -d '^-- $' "$*" ~/.Signature }
287 swiki() { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }
288 udiff() { diff -urd $* | egrep -v "^Only in |^Binary files " }
289 viless() { vim --cmd 'let no_plugin_maps = 1' -c "so \$VIMRUNTIME/macros/less.vim" "${@:--}" }
290 wikide () { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }
291 wikien() { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
292 wodeb () { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
294 which google >/dev/null 2>&1 && gex () { google "\"[ $1]\" $*" } # exact search at google
296 # Function Usage: doc packagename
297 doc() { cd /usr/share/doc/$1 && ls }
298 _doc() { _files -W /usr/share/doc -/ }
305 $SUDO apt-get -u upgrade
307 ssh $1 $SUDO apt-get update
308 # ask before the upgrade
310 ssh $1 $SUDO apt-get --no-act upgrade
311 echo -n "Process the upgrade ?"
313 if [[ $dummy == "y" ]] ; then
314 ssh $1 $SUDO apt-get -u upgrade --yes
319 # make screenshot of current desktop (use 'import' from ImageMagic)
321 [[ ! -d ~/shots ]] && mkdir ~/shots
322 #cd ~/shots ; sleep 5 ; import -window root -depth 8 -quality 80 `date "+%Y-%m-%d--%H:%M:%S"`.png
323 cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg
330 images=( *.{jpg,gif,png}(.N) )
331 if [[ $#images -eq 0 ]] ; then
332 print "No image files found"
339 # create pdf file from source code
343 a2ps --medium A4dj -E -o $output $*
347 # zsh with perl-regex - use it e.g. via:
348 # regcheck '\s\d\.\d{3}\.\d{3} Euro' ' 1.000.000 Euro'
352 pcre_match $2 && echo "regex matches" || echo "regex does not match"
354 # list files which have been modified within the last x days
355 new() { print -l *(m-$1) }
358 greph () { history 0 | grep $1 }
359 (grep --help 2>/dev/null |grep -- --color) >/dev/null && \
360 alias grep='grep --color=auto' # use colors when GNU grep with color-support
361 alias GREP='grep -i --color=auto'
363 # one blank line between each line
364 if [ -r ~/.terminfo/m/mostlike ] ; then
365 # alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
366 man2() { PAGER='dash -c "sed G | /usr/bin/less"' TERM=mostlike /usr/bin/man "$@" ; }
369 # jump between directories
370 # Copyright 2005 Nikolai Weibull <nikolai@bitwi.se>
371 # notice: option AUTO_PUSHD has to be set
375 local color=$fg_bold[blue]
377 dirs -p | while read dir; do
378 local num="${$(printf "%-4d " $i)/ /.}"
379 printf " %s $color%s$reset_color\n" $num $dir
383 read -r 'dir?Jump to directory: ' || return
384 (( dir == -1 )) && return
385 if (( dir < 0 || dir >= i )); then
386 echo d: no such directory stack entry: $dir
392 # provide useful information on globbing
399 p named pipes (FIFOs)
400 * executable plain files (0100)
401 % device files (character or block special)
402 %b block special files
403 %c character special files
404 r owner-readable files (0400)
405 w owner-writable files (0200)
406 x owner-executable files (0100)
407 A group-readable files (0040)
408 I group-writable files (0020)
409 E group-executable files (0010)
410 R world-readable files (0004)
411 W world-writable files (0002)
412 X world-executable files (0001)
413 s setuid files (04000)
414 S setgid files (02000)
415 t files with the sticky bit (01000)
416 print *(m-1) # Dateien, die vor bis zu einem Tag modifiziert wurden.
417 print *(a1) # Dateien, auf die vor einem Tag zugegriffen wurde.
418 print *(@) # Nur Links
419 print *(Lk+50) # Dateien die ueber 50 Kilobytes grosz sind
420 print *(Lk-50) # Dateien die kleiner als 50 Kilobytes sind
421 print **/*.c # Alle *.c - Dateien unterhalb von \$PWD
422 print **/*.c~file.c # Alle *.c - Dateien, aber nicht 'file.c'
423 print (foo|bar).* # Alle Dateien mit 'foo' und / oder 'bar' am Anfang
424 print *~*.* # Nur Dateien ohne '.' in Namen
425 chmod 644 *(.^x) # make all non-executable files publically readable
426 print -l *(.c|.h) # Nur Dateien mit dem Suffix '.c' und / oder '.h'
427 print **/*(g:users:) # Alle Dateien/Verzeichnisse der Gruppe >users<
428 echo /proc/*/cwd(:h:t:s/self//) # Analog zu >ps ax | awk '{print $1}'<"
431 # find out which libs define a symbol
432 # usage example: 'lcheck strcpy'
434 if [ -n "$1" ] ; then
435 nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
437 echo "Usage: lcheck <function>" >&2
443 FILES=(*~(N) .*~(N) \#*\#(N) *.o(N) a.out(N) *.core(N) *.cmo(N) *.cmi(N) .*.swp(N))
445 if [[ $NBFILES > 0 ]]; then
448 echo -n "Remove these files? [y/n] "
453 echo ">> $PWD purged, $NBFILES files removed"
455 echo "Ok. .. than not.."
461 # 'translate' looks up fot a word in a file with language-to-language
462 # translations (field separator should be " : "). A typical wordlist looks
464 # | english-word : german-transmission
465 # It's also only possible to translate english to german but not reciprocal.
466 # Use the following oneliner to turn back the sort order:
467 # $ awk -F ':' '{ print $2" : "$1" "$3 }' \
468 # /usr/local/lib/words/en-de.ISO-8859-1.vok > ~/.translate/de-en.ISO-8859-1.vok
471 -[dD]*) translate -l de-en $2
473 -[eE]*) translate -l en-de $2
476 echo "Usage: $0 { -D | -E }"
477 echo " -D == German to English"
478 echo " -E == English to German"
482 # Some quick Perl-hacks aka /useful/ oneliner
483 # bew() { perl -le 'print unpack "B*","'$1'"' }
484 # web() { perl -le 'print pack "B*","'$1'"' }
485 # hew() { perl -le 'print unpack "H*","'$1'"' }
486 # weh() { perl -le 'print pack "H*","'$1'"' }
487 # pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
488 # getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
489 # gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
490 # getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
491 # getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
492 # getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
493 # getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
494 # showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
495 # vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
496 # vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
498 # plap foo -- list all occurrences of program in the current PATH
502 echo "Usage: $0 program"
503 echo "Example: $0 zsh"
504 echo "Lists all occurrences of program in the current PATH."
506 ls -l ${^path}/*$1*(*N)
510 # Found in the mailinglistarchive from Zsh (IIRC ~1996)
515 echo "Usage: $0 command"
518 cmd=(${(f)"$(grep -w $1 $HISTFILE | sort | uniq | pr -tn)"})
519 print -l $cmd | less -F
520 echo -n "enter number of desired command [1 - $(( ${#cmd[@]} - 1 ))]: "
523 print -z "${cmd[$answer]#*$TAB}"
527 mcd() { mkdir -p "$@"; cd "$@" } # mkdir && cd
530 cl() { cd $1 && ls -a }
532 # Use vim to convert plaintext to HTML
533 2html() { vim -u NONE -n -c ':syntax on' -c ':so $VIMRUNTIME/syntax/2html.vim' -c ':wqa' $1 > /dev/null 2> /dev/null }
535 # Usage: simple-extract <file>
536 # Description: extracts archived files (maybe)
541 *.tar.bz2) bzip2 -v -d $1 ;;
542 *.tar.gz) tar -xvzf $1 ;;
545 *.bz2) bzip2 -d $1 ;;
547 *.gz) gunzip -d $1 ;;
548 *.tar) tar -xvf $1 ;;
549 *.tgz) gunzip -d $1 ;;
550 *.tbz2) tar -jxvf $1 ;;
552 *.Z) uncompress $1 ;;
553 *) echo "'$1' Error. Please go away" ;;
556 echo "'$1' is not a valid file"
560 # Usage: smartcompress <file> (<type>)
561 # Description: compresses files or a directory. Defaults to tar.gz
565 tgz | tar.gz) tar -zcvf$1.$2 $1 ;;
566 tbz2 | tar.bz2) tar -jcvf$1.$2 $1 ;;
567 tar.Z) tar -Zcvf$1.$2 $1 ;;
568 tar) tar -cvf$1.$2 $1 ;;
569 gz | gzip) gzip $1 ;;
570 bz2 | bzip2) bzip2 $1 ;;
572 echo "Error: $2 is not a valid compression type"
576 smartcompress $1 tar.gz
580 # Usage: show-archive <archive>
581 # Description: view archive without unpack
586 *.tar.gz) gunzip -c $1 | tar -tf - -- ;;
588 *.tgz) tar -ztf $1 ;;
589 *.zip) unzip -l $1 ;;
591 *) echo "'$1' Error. Please go away" ;;
594 echo "'$1' is not a valid archive"
599 if [[ -e $1 || -h $1 ]]; then
604 if [[ -e $file || -L $file ]]; then
605 if [[ -L $file ]]; then
606 echo `ls -ld $file | perl -ane 'print $F[7]'` '->'
607 folsym `perl -le '$file = $ARGV[0];
608 $dest = readlink $file;
609 if ($dest !~ m{^/}) {
610 $file =~ s{(/?)[^/]*$}{$1$dest};
614 $file =~ s{/{2,}}{/}g;
615 while ($file =~ s{[^/]+/\.\./}{}) {
618 $file =~ s{^(/\.\.)+}{};
628 # Use 'view' to read manpages, if u want colors, regex - search, ...
630 # It's shameless stolen from <http://www.vim.org/tips/tip.php?tip_id=167>
631 vman() { man $* | col -b | view -c 'set ft=man nomod nolist' - }
633 # search for various types or README file in dir and display them in $PAGER
634 # function readme() { $PAGER -- (#ia3)readme* }
637 files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))
641 print 'No README files.'
645 # find all suid files in $PATH
646 # suidfind() { ls -latg $path | grep '^...s' }
647 suidfind() { ls -latg $path/*(sN) }
649 # See above but this is /better/ ... anywise ..
651 print 'Output will be written to ~/suid_* ...'
652 $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
653 $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
654 $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
655 $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
668 # a small check to see which DIR is located on which server/partition.
669 # stolen and modified from Sven's zshrc.forall
673 (cd $dir; echo "-<$dir>"; du -shx .; echo);
677 # $ show_print `cat /etc/passwd`
679 for argument in "${@}"
681 for ((i = 1; i <= ${#1} ;i++)) {
682 print -n "${argument[i]}"
692 print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
693 print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
694 print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
695 print "Login.: $LOGNAME (UID = $EUID) on $HOST"
696 print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
697 print "Uptime:$(uptime)"
704 cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
705 cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
706 echo " * Would you like to burn the cd now? (yes/no)"
709 [ "$input" = "yes" ]; then
710 echo " ! Burning Audio CD"
714 echo " ! Invalid response."
720 cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
721 echo " * Should I remove the temporary files? (yes/no)"
723 if [ "$input" = "yes" ]; then
724 echo " ! Removing Temporary Files."
729 echo " ! Invalid response."
735 for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
736 for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
737 for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
739 for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
743 echo " * Volume name "
745 echo " * ISO Name (ie. tmp.iso)"
747 echo " * Directory or File"
749 mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files
752 # generate thumbnails ;)
754 rm -rf thumb-* index.html
758 <title>Images</title>
761 for f in *.(gif|jpeg|jpg|png)
763 convert -size 100x200 "$f" -resize 100x200 thumb-"$f"
764 echo " <a href=\"$f\"><img src=\"thumb-$f\"></a>" >> index.html
768 </html>" >> index.html
771 # unset all limits (see zshbuiltins(1) /ulimit for details)
782 # ogg2mp3 with bitrate of 192
784 oggdec -o - ${1} | lame -b 192 - ${1:r}.mp3
787 # RFC 2396 URL encoding in Z-Shell
789 setopt localoptions extendedglob
791 print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
794 # get x-lite voip software
798 [ -d ~/tmp ] || mkdir ~/tmp
800 echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
801 if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
802 unp X-Lite_Install.tar.gz && echo done || echo failed
804 echo "Error while downloading." ; return 1
806 if [ -x xten-xlite/xtensoftphone ] ; then
807 echo "Execute xten-xlite/xtensoftphone to start xlite."
815 echo "Downloading debian package of skype."
816 echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
817 wget http://www.skype.com/go/getskype-linux-deb
818 $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
821 # get beta-version of skype
825 echo "Downloading debian package of skype (beta version)."
826 wget http://www.skype.com/go/getskype-linux-beta-deb
827 $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
830 # get gzimo (VoIP software)
834 echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
836 $SUDO apt-get install gconf2-common libgconf2-4
837 wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
838 $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
841 # get AIR - Automated Image and Restore
845 [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
847 wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
848 tar zxf air-$VER.tar.gz
850 INTERACTIVE=no $SUDO ./install-air-1.2.8
851 [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
854 # get specific git commitdiff
856 if [ -z $GITTREE ] ; then
857 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
859 if ! [ -z $1 ] ; then
860 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commitdiff;h=$1"
862 echo "Usage: git-get-diff <commit>"
866 # get specific git commit
868 if [ -z $GITTREE ] ; then
869 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
871 if ! [ -z $1 ] ; then
872 ${=BROWSER} "http://kernel.org/git/?p=$GITTREE;a=commit;h=$1"
874 echo "Usage: git-get-commit <commit>"
878 # get specific git diff
879 git-get-plaindiff() {
880 if [ -z $GITTREE ] ; then
881 GITTREE='linux/kernel/git/torvalds/linux-2.6.git'
883 if ! [ -z $1 ] ; then
884 wget "http://kernel.org/git/?p=$GITTREE;a=commitdiff_plain;h=$1" -O $1.diff
886 echo 'Usage: git-get-plaindiff '
890 # log 'make install' output
891 # http://strcat.de/blog/index.php?/archives/335-Software-sauber-deinstallieren...html
893 [[ ! -d ~/.errorlogs ]] && mkdir ~/.errorlogs
894 =make -n install > ~/.errorlogs/${PWD##*/}-makelog
899 indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs $*
902 # highlight important stuff in diff output, usage example: hg diff | hidiff
903 [ -x =histring ] && \
904 alias hidiff="histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'"
906 # rename pictures based on information found in exif headers
908 if [ $# -lt 1 ] ; then
909 echo 'Usage: jpgrename $FILES' >& 2
912 echo -n 'Checking for jhead with version newer than 1.9: '
913 jhead_version=`jhead -h | grep 'used by most Digital Cameras. v.*' | awk '{print $6}' | tr -d v`
914 if [[ $jhead_version > '1.9' ]]; then
915 echo 'success - now running jhead.'
916 jhead -n%Y-%m-%d_%Hh%M_%f $*
918 echo 'failed - exiting.'
924 # mercurial related stuff {{{
925 if type -p hg >/dev/null 2>&1 ; then
926 # gnu like diff for mercurial
927 # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
929 for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
932 # build debian package
933 alias hbp='hg-buildpackage'
935 # diffstat for specific version of a mercurial repository
936 # hgstat => display diffstat between last revision and tip
937 # hgstat 1234 => display diffstat between revision 1234 and tip
939 [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
942 # get current mercurial tip via hg itself
946 if [ -f mercurial-tree/.hg ] ; then
948 echo "Running hg pull for retreiving latest version..."
950 echo "Finished update. Building mercurial"
952 echo "Setting \$PATH to $PWD:\$PATH..."
953 export PATH="$PWD:$PATH"
955 echo "Downloading mercurial via hg"
956 hg clone http://selenic.com/repo/hg mercurial-tree
958 echo "Building mercurial"
960 echo "Setting \$PATH to $PWD:\$PATH..."
961 export PATH="$PWD:$PATH"
962 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
963 # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
964 # export PYTHONPATH=${HOME}/lib/python
968 fi # end of check whether we have the 'hg'-executable
970 # get current mercurial snapshot
974 if [ -f mercurial-snapshot.tar.gz ] ; then
975 echo "mercurial-snapshot.tar.gz exists already, skipping download."
977 echo "Downloading mercurial snapshot"
978 wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
980 echo "Unpacking mercurial-snapshot.tar.gz"
981 tar zxf mercurial-snapshot.tar.gz
982 cd mercurial-snapshot/
983 echo "Installing required build-dependencies"
985 $SUDO apt-get install python2.4-dev
986 echo "Building mercurial"
988 echo "Setting \$PATH to $PWD:\$PATH..."
989 export PATH="$PWD:$PATH"
990 echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
994 # some useful commands often hard to remember - let's grep for them {{{
996 # Work around ion/xterm resize bug.
997 #if [ "$SHLVL" = 1 ]; then
998 # if [ -x `which resize 2>/dev/null` ]; then
999 # eval `resize </dev/null`
1004 # /usr/bin/jackd -dalsa -dhw:0 -r48000 -p1024 -n2
1005 # now play audio file:
1006 # alsaplayer -o jack foobar.mp3
1008 # send files via netcat
1010 # send() {j=$*; tar cpz ${j/%${!#}/}|nc -w 1 ${!#} 51330;}
1012 # alias receive='nc -vlp 51330 | tar xzvp'
1015 # dh_make -e foo@localhost -f $1
1016 # dpkg-buildpackage -rfakeroot
1018 # dpkg-scanpackages ./ /dev/null | gzip > Packages.gz
1019 # dpkg-scansources . | gzip > Sources.gz
1020 # grep-dctrl --field Maintainer $* /var/lib/apt/lists/*
1023 # convert -geometry 200x200 -interlace LINE -verbose
1024 # ldapsearch -x -b "OU=Bedienstete,O=tug" -h ldap.tugraz.at sn=$1
1025 # ps -ao user,pcpu,start,command
1026 # gpg --keyserver blackhole.pca.dfn.de --recv-keys
1027 # xterm -bg black -fg yellow -fn -misc-fixed-medium-r-normal--14-140-75-75-c-90-iso8859-15 -ah
1028 # nc -vz $1 1-1024 # portscan via netcat
1029 # wget --mirror --no-parent --convert-links
1031 # autoload -U tetris; zle -N tetris; bindkey '...' ; echo "press ... for playing tennis"
1033 # modify console cursor
1034 # see http://www.tldp.org/HOWTO/Framebuffer-HOWTO-5.html
1035 # print $'\e[?96;0;64c'
1038 # finally source a local zshrc and grmlsmall-specific configuration {{{
1040 # The following file is used to remove zsh-config-items that do not work
1041 # in grml-small by default.
1042 # If you do not want these adjustments (for whatever reason),
1043 # there are three ways to accomplish that:
1044 # a) at the beginning of this file (variables section), set
1045 # $GRMLSMALL_SPECIFIC to 0 or comment out the variable definition.
1046 # b) remove/rename .zshrc.grmlsmall
1047 # c) comment out the following line
1048 (( GRMLSMALL_SPECIFIC > 0 )) && isgrmlsmall && source ~/.zshrc.grmlsmall
1050 # this allows us to stay in sync with /etc/skel/.zshrc
1051 # through 'ln -s /etc/skel/.zshrc ~/.zshrc' and put own
1052 # modifications in ~/.zshrc.local
1053 if [ -r ~/.zshrc.local ] ; then
1058 ## END OF FILE #################################################################
1059 # vim:foldmethod=marker