+
+# provide useful information on globbing
+ H-Glob() {
+ echo -e "
+ / directories
+ . plain files
+ @ symbolic links
+ = sockets
+ p named pipes (FIFOs)
+ * executable plain files (0100)
+ % device files (character or block special)
+ %b block special files
+ %c character special files
+ r owner-readable files (0400)
+ w owner-writable files (0200)
+ x owner-executable files (0100)
+ A group-readable files (0040)
+ I group-writable files (0020)
+ E group-executable files (0010)
+ R world-readable files (0004)
+ W world-writable files (0002)
+ X world-executable files (0001)
+ s setuid files (04000)
+ S setgid files (02000)
+ t files with the sticky bit (01000)
+
+ print *(m-1) # Files modified up to a day ago
+ print *(a1) # Files accessed a day ago
+ print *(@) # Just symlinks
+ print *(Lk+50) # Files bigger than 50 kilobytes
+ print *(Lk-50) # Files smaller than 50 kilobytes
+ print **/*.c # All *.c files recursively starting in \$PWD
+ print **/*.c~file.c # Same as above, but excluding 'file.c'
+ print (foo|bar).* # Files starting with 'foo' or 'bar'
+ print *~*.* # All Files that do not contain a dot
+ chmod 644 *(.^x) # make all plain non-executable files publically readable
+ print -l *(.c|.h) # Lists *.c and *.h
+ print **/*(g:users:) # Recursively match all files that are owned by group 'users'
+ echo /proc/*/cwd(:h:t:s/self//) # Analogous to >ps ax | awk '{print $1}'<"
+ }
+ alias help-zshglob=H-Glob
+
+ type -p qma &>/dev/null && alias ?='qma zshall'
+
+ # grep for running process, like: 'any vim'
+ any() {
+ if [ -z "$1" ] ; then
+ echo "any - grep for process(es) by keyword" >&2
+ echo "Usage: any <keyword>" >&2 ; return 1
+ else
+ local STRING=$1
+ local LENGTH=$(expr length $STRING)
+ local FIRSCHAR=$(echo $(expr substr $STRING 1 1))
+ local REST=$(echo $(expr substr $STRING 2 $LENGTH))
+ ps xauwww| grep "[$FIRSCHAR]$REST"
+ fi
+ }
+
+ # After resuming from suspend, system is paging heavilly, leading to very bad interactivity.
+ # taken from $LINUX-KERNELSOURCE/Documentation/power/swsusp.txt
+ [ -r /proc/1/maps ] && deswap() {
+ print 'Reading /proc/[0-9]*/maps and sending output to /dev/null, this might take a while.'
+ cat $(sed -ne 's:.* /:/:p' /proc/[0-9]*/maps | sort -u | grep -v '^/dev/') > /dev/null
+ print 'Finished, running "swapoff -a; swapon -a" may also be useful.'
+ }
+
+ # print hex value of a number
+ hex() {
+ [ -n "$1" ] && printf "%x\n" $1 || { print 'Usage: hex <number-to-convert>' ; return 1 }
+ }
+
+ # calculate (or eval at all ;-)) with perl => p[erl-]eval
+ # hint: also take a look at zcalc -> 'autoload zcalc' -> 'man zshmodules | less -p MATHFUNC'
+ peval() {
+ [ -n "$1" ] && CALC="$*" || print "Usage: calc [expression]"
+ perl -e "print eval($CALC),\"\n\";"
+ }
+ functions peval &>/dev/null && alias calc=peval
+
+ # brltty seems to have problems with utf8 environment and/or font Uni3-Terminus16 under
+ # certain circumstances, so work around it, no matter which environment we have
+ brltty() {
+ if [ -z "$DISPLAY" ] ; then
+ consolechars -f /usr/share/consolefonts/default8x16.psf.gz
+ command brltty "$@"
+ else
+ command brltty "$@"
+ fi
+ }
+
+ # Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html
+ # bash() {
+ # NO_SWITCH="yes" command bash "$@"
+ # }
+ # restart () {
+ # exec $SHELL $SHELL_ARGS "$@"
+ # }
+
+# }}}
+
+# log out? set timeout in seconds {{{
+# TMOUT=1800
+# do not log out in some specific terminals:
+# if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]]; then
+# unset TMOUT
+# fi
+# }}}
+
+# {{{ make sure our environment is clean regarding colors
+ for color in BLUE RED GREEN CYAN WHITE ; unset $color