* /etc/zsh/zshrc: fma has been renamed into qma, adjust references
[grml-etc-core.git] / etc / zsh / zshrc
index e47b106..75013ea 100644 (file)
     isgrmlsmall() { return 1 }
   fi
 
+  # are we running within an utf environment?
+  isutfenv() {
+    case "$LANG $CHARSET $LANGUAGE" in
+      *utf*) return 0 ;;
+      *)     return 1 ;;
+    esac
+  }
+
 # check for user, if not running as root set $SUDO to sudo
  (( EUID != 0 )) && SUDO='sudo' || SUDO=''
 
@@ -306,7 +314,8 @@ fi
 # }}}
 
 # {{{ set some important options
-  umask 022
+  # umask 022
+  umask 002
 
 # history:
   setopt append_history       # append history list to the history file (important for multiple parallel zsh sessions!)
@@ -535,7 +544,11 @@ ${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< %# "
 
 # truecrypt; use e.g. via 'truec /dev/ice' /mnt/ice' or 'truec -i'
   if [ -x /usr/sbin/truecrypt ] ; then
-     alias truec='truecrypt --mount-options "rw,sync,dirsync,users,uid=1000,gid=users,umask=077" '
+     if isutfenv ; then
+        alias truec='truecrypt --mount-options "rw,sync,dirsync,users,uid=1000,gid=users,umask=077,utf8" '
+     else
+        alias truec='truecrypt --mount-options "rw,sync,dirsync,users,uid=1000,gid=users,umask=077" '
+     fi
   fi
 
   zsh-help(){print "$bg[white]$fg[black]
@@ -546,7 +559,7 @@ Main configuration of zsh happens in /etc/zsh/zshrc (global)
 and /etc/skel/.zshrc which is copied to \$HOME/.zshrc once.
 The files are part of the package grml-etc-core, if you want to
 use them on a non-grml-system just get the tar.gz from
-http://grml.org/repos/ or get the files from the mercurial
+http://deb.grml.org/ or get the files from the mercurial
 repository:
 
   http://hg.grml.org/grml-etc-core/raw-file/tip/etc/skel/.zshrc
@@ -820,9 +833,15 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"."
 # shell functions {{{
   setenv()  { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }  # csh compatibility
   freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
-  manzsh()  {  /usr/bin/man zshall |  vim -c "se ft=man| se hlsearch" +/"$1" - ; }
-#  manzsh()  { /usr/bin/man zshall |  most +/"$1" ; }
-#  manzsh()  { man zshall | $MYLESS -p $1 ; }
+
+  # fast manual access
+  if type -p qma &>/dev/null ; then
+     manzsh()  { qma zshall "$1" }
+  else
+     manzsh()  { /usr/bin/man zshall |  vim -c "se ft=man| se hlsearch" +/"$1" - ; }
+     # manzsh()  { /usr/bin/man zshall |  most +/"$1" ; }
+     # manzsh()  { man zshall | $MYLESS -p $1 ; }
+  fi
 
 # use "dchange <package-name>" to view Debian's changelog of the package:
   dchange() {
@@ -830,10 +849,10 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"."
        most /usr/share/doc/${1}/changelog.Debian.gz
     else
        if [ -r /usr/share/doc/${1}/changelog.gz ] ; then
-         most /usr/share/doc/${1}/changelog.gz
+          most /usr/share/doc/${1}/changelog.gz
        else
-         echo "No changelog for package $1 found, sorry."
-         return 1
+          echo "No changelog for package $1 found, sorry."
+          return 1
        fi
     fi
   }
@@ -869,9 +888,67 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"."
   for i in Start Restart Stop Force-Reload Reload ; do
     eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} \$2 ; }"
   done
-# now the completion for this:
+  # now the completion for this:
   compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Force-Reload Reload
  fi
+
+# 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
+  }
+
 # }}}
 
 # {{{ make sure our environment is clean regarding colors