The "Frank Terbeck is my zsh hero" release.
authorMichael Prokop <mika@grml.org>
Wed, 25 Oct 2006 21:52:37 +0000 (23:52 +0200)
committerMichael Prokop <mika@grml.org>
Wed, 25 Oct 2006 21:52:37 +0000 (23:52 +0200)
  * Update /etc/zsh/site-functions/_hg to latest version from
    http://hg.intevation.org/mercurial/crew
  * Added /etc/zsh/site-functions/_grmlinitd for better completion
    of "Start Restart Stop Reload" with initscripts, thanks - Frank
    Terbeck!
  * /etc/zsh/zshrc:
    - use is-at-least for is4[2]-functions if possible
    - bugfix for $2 in initscripts "Start Restart Stop Reload"
      function (thanks, Frank Terbeck!)
    - use zsh's color capabilities if the module is present
      (thanks, Frank Terbeck!)
  * /etc/zsh/zshenv:
    - set /bin instead of /bin/ in $PATH
  * /etc/skel/.zshrc:
    - updated alias fbmplayer (thanks, wuehlmaus!)
    - added function gex (google exact search, thanks wuehlmaus!)
    - added gethgsnap and gethgclone for retrieving mercurial
    - use $SUDO in the whole file instead of $RUNASROOT
    - use 'setopt errreturn' in some functions

debian/changelog
etc/skel/.zshrc
etc/zsh/site-functions/_grmlinitd [new file with mode: 0644]
etc/zsh/site-functions/_hg
etc/zsh/zshenv
etc/zsh/zshrc

index 6852e68..72ea5f0 100644 (file)
@@ -1,3 +1,29 @@
+grml-etc-core (0.1-26) unstable; urgency=low
+
+  The "Frank Terbeck is my zsh hero" release.
+
+  * Update /etc/zsh/site-functions/_hg to latest version from
+    http://hg.intevation.org/mercurial/crew
+  * Added /etc/zsh/site-functions/_grmlinitd for better completion
+    of "Start Restart Stop Reload" with initscripts, thanks - Frank
+    Terbeck!
+  * /etc/zsh/zshrc:
+    - use is-at-least for is4[2]-functions if possible
+    - bugfix for $2 in initscripts "Start Restart Stop Reload"
+      function (thanks, Frank Terbeck!)
+    - use zsh's color capabilities if the module is present
+      (thanks, Frank Terbeck!)
+  * /etc/zsh/zshenv:
+    - set /bin instead of /bin/ in $PATH
+  * /etc/skel/.zshrc: 
+    - updated alias fbmplayer (thanks, wuehlmaus!)
+    - added function gex (google exact search, thanks wuehlmaus!)
+    - added gethgsnap and gethgclone for retrieving mercurial
+    - use $SUDO in the whole file instead of $RUNASROOT
+    - use 'setopt errreturn' in some functions
+
+ -- Michael Prokop <mika@grml.org>  Tue, 24 Oct 2006 20:35:29 +0200
+
 grml-etc-core (0.1-25) unstable; urgency=low
 
   * /etc/skel/.zshrc: add functions for mercurial
index de649eb..2455545 100644 (file)
 
 # console stuff
   alias cmplayer='mplayer -vo fbdev'
-  alias fbmplayer='mplayer -vo fbdev'
+#  alias fbmplayer='mplayer -vo fbdev'
+  alias fbmplayer='mplayer -vo fbdev -fs -zoom'
   alias fblinks='links2 -driver fb'
 
 # ignore ~/.ssh/known_hosts entries
   [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
 
 # check whether Debian's package management (dpkg) is running
-  alias check_dpkg_running="sudo dpkg_running"
+  alias check_dpkg_running="$SUDO dpkg_running"
 # }}}
 
 ## useful functions {{{
   wikien()  { ${=BROWSER} http://en.wikipedia.org/wiki/"$*" }
   wodeb ()  { ${=BROWSER} "http://packages.debian.org/cgi-bin/search_contents.pl?word=$1&version=${2:-unstable}" }
 
+  which google >/dev/null 2>&1 && gex () { google "\"[ $1]\" $*" } # exact search at google
+
 # Function Usage: doc packagename
   doc() { cd /usr/share/doc/$1 && ls }
   _doc() { _files -W /usr/share/doc -/ }
 # debian upgrade
   upgrade () {
     if [ -z $1 ] ; then
-        sudo apt-get update
-        sudo apt-get -u upgrade
+        $SUDO apt-get update
+        $SUDO apt-get -u upgrade
     else
-        ssh $1 sudo apt-get update
+        ssh $1 $SUDO apt-get update
         # ask before the upgrade
         local dummy
-        ssh $1 sudo apt-get --no-act upgrade
+        ssh $1 $SUDO apt-get --no-act upgrade
         echo -n "Process the upgrade ?"
         read -q dummy
         if [[ $dummy == "y" ]] ; then
-            ssh $1 sudo apt-get -u upgrade --yes
+            ssh $1 $SUDO apt-get -u upgrade --yes
         fi
     fi
   }
   suidfind() { ls -latg $path/*(sN) }
 
 # See above but this is /better/ ... anywise ..
-#  Note: Add $USER and 'find' with "NOPASSWD" in your /etc/sudoers or run it
-#        as root (UID == 0)
   findsuid() {
-    if [ UID != 0 ] ; then
-      print 'Not running as root. Trying to run via sudo...'
-      RUNASROOT=sudo
-    fi
-        print 'Output will be written to ~/suid_* ...'
-        $RUNASROOT find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
-        $RUNASROOT find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
-        $RUNASROOT find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
-        $RUNASROOT find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
-        print 'Finished'
+    print 'Output will be written to ~/suid_* ...'
+    $SUDO find / -type f \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suidfiles.`date "+%Y-%m-%d"`.out 2>&1
+    $SUDO find / -type d \( -perm -4000 -o -perm -2000 \) -ls > ~/suid_suiddirs.`date "+%Y-%m-%d"`.out 2>&1
+    $SUDO find / -type f \( -perm -2 -o -perm -20 \) -ls > ~/suid_writefiles.`date "+%Y-%m-%d"`.out 2>&1
+    $SUDO find / -type d \( -perm -2 -o -perm -20 \) -ls > ~/suid_writedirs.`date "+%Y-%m-%d"`.out 2>&1
+    print 'Finished'
   }
 
 # Reload functions.
 
 # get x-lite voip software
   getxlite() {
-   [ -d ~/tmp ] || mkdir ~/tmp
-   cd ~/tmp
-   echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
-   if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
-     unp X-Lite_Install.tar.gz && echo done || echo failed
-   else
-     echo "Error while downloading." ; return 1
-   fi
-   if [ -x xten-xlite/xtensoftphone ] ; then
-     echo "Execute xten-xlite/xtensoftphone to start xlite."
-   fi
+    setopt errreturn
+    [ -d ~/tmp ] || mkdir ~/tmp
+    cd ~/tmp
+    echo "Downloading http://www.counterpath.com/download/X-Lite_Install.tar.gz and storing it in ~/tmp:"
+    if wget http://www.counterpath.com/download/X-Lite_Install.tar.gz ; then
+       unp X-Lite_Install.tar.gz && echo done || echo failed
+    else
+       echo "Error while downloading." ; return 1
+    fi
+    if [ -x xten-xlite/xtensoftphone ] ; then
+       echo "Execute xten-xlite/xtensoftphone to start xlite."
+    fi
    }
 
 # get skype
   getskype() {
-   echo "Downloading debian package of skype."
-   echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
-   wget http://www.skype.com/go/getskype-linux-deb
-   # mkdir skype.install
-   # dpkg-deb --extract skype_*.deb skype.install/
-   # dpkg-deb --control skype_*.deb skype.install/DEBIAN
-   # sed -i 's/libqt3c102-mt/libqt3-mt/' skype.install/DEBIAN/control
-   # dpkg --build skype.install
-   sudo dpkg -i skype_debian-*.deb && echo "skype installed."
+    setopt errreturn
+    echo "Downloading debian package of skype."
+    echo "Notice: If you want to use a more recent skype version run 'getskypebeta'."
+    wget http://www.skype.com/go/getskype-linux-deb
+    $SUDO dpkg -i skype_debian-*.deb && echo "skype installed."
   }
 
 # get beta-version of skype
   getskypebeta() {
-   echo "Downloading debian package of skype (beta version)."
-   wget http://www.skype.com/go/getskype-linux-beta-deb
-   sudo dpkg -i skype-beta*.deb && echo "skype installed."
+    setopt errreturn
+    echo "Downloading debian package of skype (beta version)."
+    wget http://www.skype.com/go/getskype-linux-beta-deb
+    $SUDO dpkg -i skype-beta*.deb && echo "skype installed."
   }
 
 # get gzimo (voicp software)
   getgizmo() {
+    setopt errreturn
     echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
-    sudo apt-get update
-    sudo apt-get install gconf2-common libgconf2-4
+    $SUDO apt-get update
+    $SUDO apt-get install gconf2-common libgconf2-4
     wget $(lynx --dump http://www.gizmoproject.com/download-linux.html | awk '/\.deb/ {print $2" "}' | tr -d '\n')
-    sudo dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
+    $SUDO dpkg -i libsipphoneapi*.deb bonjour_*.deb gizmo-*.deb && echo "gizmo installed."
   }
 
 # get AIR - Automated Image and Restore
   getair() {
+    setopt errreturn
     [ -w . ] || { echo 'Error: you do not have write permissions in this directory. Exiting.' ; return 1 }
     local VER='1.2.8'
     wget http://puzzle.dl.sourceforge.net/sourceforge/air-imager/air-$VER.tar.gz
     tar zxf air-$VER.tar.gz
     cd air-$VER
-    INTERACTIVE=no sudo ./install-air-1.2.8
-    [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && sudo air
+    INTERACTIVE=no $SUDO ./install-air-1.2.8
+    [ -x /usr/local/bin/air ] && [ -n "$DISPLAY" ] && $SUDO air
   }
 
 # get specific git commitdiff
     hgstat() {
       [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
     }
-  fi
+
+  # get current mercurial tip via hg itself and install it in $HOME
+  gethgclone() {
+    setopt local_options
+    setopt errreturn
+    if [ -f mercurial-tree/.hg ] ; then
+      cd mercurial-tree
+      echo "Running hg pull for retreiving latest version..."
+      hg pull
+      echo "Finished update. Building tree now..."
+      make local
+      echo "Setting \$PATH to $PWD:\$PATH..."
+      export PATH="$PWD:$PATH"
+    else
+      hg clone http://selenic.com/repo/hg mercurial-tree
+      cd mercurial-tree
+      make local
+      echo "Setting \$PATH to $PWD:\$PATH..."
+      export PATH="$PWD:$PATH"
+      # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
+      echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
+      # export PYTHONPATH=${HOME}/lib/python
+    fi
+    setopt LOCAL_OPTIONS
+  }
+
+  fi # end of check whether we have the 'hg'-executable
+
+  # get and install current mercurial snapshot in $HOME
+  gethgsnap() {
+    setopt local_options
+    setopt errreturn
+    echo "Downloading mercurial snapshot"
+    wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
+    tar zxf mercurial-snapshot.tar.gz
+    cd mercurial-snapshot/
+    $SUDO apt-get update
+    $SUDO apt-get install python2.4-dev
+    make local
+    # make install-home-bin
+    echo "Setting \$PATH to $PWD:\$PATH..."
+    export PATH="$PWD:$PATH"
+    # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
+    # export PYTHONPATH=${HOME}/lib/python
+    echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
+    # echo "Notice: make sure \$HOME/bin is inside \$PATH!"
+  }
 # }}}
 
 # some useful commands often hard to remember - let's grep for them {{{
diff --git a/etc/zsh/site-functions/_grmlinitd b/etc/zsh/site-functions/_grmlinitd
new file mode 100644 (file)
index 0000000..177dfd5
--- /dev/null
@@ -0,0 +1,4 @@
+#compdef Start Restart Stop Reload
+local scripts
+scripts=( ${$(print /etc/init.d/*(x)):t} )
+_describe "service startup script" scripts
index bca462e..f4f3b58 100644 (file)
 
 local curcontext="$curcontext" state line
 typeset -A opt_args
-local subcmds repos tags newFiles addedFiles includeExclude
+local subcmds repos tags newFiles addedFiles includeExclude commitMessage
+
+_mq_state () {
+  case "$state" in
+    (qapplied)
+      compadd $(hg qapplied)
+    ;;
+    (qunapplied)
+      compadd $(hg qunapplied)
+    ;;
+  esac
+}
 
 tags=($(hg tags 2> /dev/null | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//'))
 subcmds=($(hg -v help | sed -e '1,/^list of commands:/d' \
@@ -27,6 +38,14 @@ includeExclude=(
         '*-X-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/'
         '*--exclude-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/')
 
+commitMessage=(
+        '(-m --message -l --logfile --edit)-e[edit commit message]'
+        '(-m --message -l --logfile -e)--edit[edit commit message]'
+        '(-e --edit -l --logfile --message)-m[use <text> as commit message]:message:'
+        '(-e --edit -l --logfile -m)--message[use <text> as commit message]:message:'
+        '(-e --edit -m --message --logfile)-l[read the commit message from <file>]:log file:_files'
+        '(-e --edit -m --message -l)--logfile[read the commit message from <file>]:log file:_files')
+
 if [[ $service == "hg" ]]; then
     _arguments -C -A "-*" \
     '(--repository)-R[repository root directory]:root:_files -/' \
@@ -419,6 +438,43 @@ case $service in
         # no arguments for these commands
     ;;
 
+    # MQ commands
+    (qdel*|qrm|qrem*)
+        _arguments \
+            {-k,--keep}'[keep patch file]' \
+            {-r,--rev}'[revision]:applied patch:->qapplied' \
+            '*:unapplied patches:->qunapplied'
+        _mq_state
+    ;;
+
+    (qnew)
+        _arguments $commitMessage \
+            {-f,--force}'[import uncommitted changes into patch]' \
+            ':patch name:'
+    ;;
+
+    (qpo*)
+        applied=( $(hg qapplied) )
+        _arguments \
+            (1){-a,--all}'[pop all patches]' \
+            {-f,--force}'[forget any local changes]' \
+            ':applied patch:->qapplied'
+        _mq_state
+    ;;
+
+    (qpu*)
+        _arguments \
+            (1){-a,--all}'[apply all patches]' \
+            {-f,--force}'[apply if the patch has rejects]' \
+            ':unapplied patch:->qunapplied'
+        _mq_state
+    ;;
+    (qref*)
+        _arguments $commitMessage $includeExclude \
+            {-g,--git}'[use git extended diff format]' \
+            {-s,--short}'[short refresh]'
+    ;;
+
     (*)
         _message "unknown hg command completion: $service"
     ;;
index 26c1e83..d33bb5d 100644 (file)
@@ -48,7 +48,7 @@
   if [ -r /etc/gentoo-release ] ; then
      [ -r /etc/profile.env ] && source /etc/profile.env
        if (( EUID != 0 )); then
-          PATH="$HOME/bin:/bin/:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/games:/usr/NX/bin:$PATH"
+          PATH="$HOME/bin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/games:/usr/NX/bin:$PATH"
        else
           PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/NX/bin:$PATH"
        fi
@@ -58,7 +58,7 @@
        [ -d /cdrom/addons/ ] && ADDONS=':/cdrom/addons/'
     fi
     if (( EUID != 0 )); then
-      PATH="$HOME/bin:/bin/:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/games:/usr/NX/bin$ADDONS"
+      PATH="$HOME/bin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/games:/usr/NX/bin$ADDONS"
     else
       PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/NX/bin$ADDONS"
     fi
index 936c704..99642aa 100644 (file)
@@ -3,7 +3,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Sam Okt 21 16:20:30 CEST 2006 [mika]
+# Latest change: Mit Okt 25 23:44:27 CEST 2006 [mika]
 ################################################################################
 # This file is sourced only for interactive shells. It
 # should contain commands to set up aliases, functions,
 
 # {{{ check for version/system
 # check for versions (compatibility reasons)
-  is4(){
-    [[ $ZSH_VERSION == 4.* ]] && return 0
-    return 1
-  }
-
-# current release
-  is42(){
-    [[ $ZSH_VERSION == 4.<2->* ]] && return 0
-    return 1
-  }
+  if autoload is-at-least && is-at-least ; then
+     is4() { is-at-least 4 }
+     is42() { is-at-least 4.2 }
+  else
+    is4(){
+      [[ $ZSH_VERSION == 4.* ]] && return 0
+      return 1
+    }
+    is42(){
+      [[ $ZSH_VERSION == 4.<2->* ]] && return 0
+      return 1
+    }
+  fi
 
 # grml specific stuff
   isgrml(){
@@ -326,13 +329,24 @@ fi
       esac
   }
 
+# set colors
+  if autoload colors && colors ; then
+     BLUE="%{${fg[blue]}%}"
+     RED="%{${fg_bold[red]}%}"
+     GREEN="%{${fg[green]}%}"
+     CYAN="%{${fg[cyan]}%}"
+     WHITE="%{${fg[white]}%}"
+     NO_COLOUR="%{${reset_color}%}"
+  else
+     BLUE="%{\e[1;34m%}"
+     RED="%{\e[1;31m%}"
+     GREEN="%{\e[1;32m%}"
+     CYAN="%{\e[1;36m%}"
+     WHITE="%{\e[1;37m%}"
+     NO_COLOUR="%{\e[0m%}"
+  fi
+
   EXITCODE="%(?..%?%1v )"
-  local BLUE="%{\e[1;34m%}"
-  local RED="%{\e[1;31m%}"
-  local GREEN="%{\e[1;32m%}"
-  local CYAN="%{\e[1;36m%}"
-  local WHITE="%{\e[1;37m%}"
-  local NO_COLOUR="%{\e[0m%}"
   PS2='`%_> '       # secondary prompt, printed when the shell needs more information to complete a command.
   PS3='?# '         # selection prompt used within a select loop.
   PS4='+%N:%i:%_> ' # the execution trace prompt (setopt xtrace). default: '+%N:%i>'
@@ -723,13 +737,16 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"."
 # use it e.g. via 'Restart apache2'
  if [ -d /etc/init.d ] ; then
   for i in Start Restart Stop Reload ; do
-    eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} $2 ; }"
+    eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} \$2 ; }"
   done
 # now the completion for this:
   compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Reload
  fi
 # }}}
 
+# make sure our environment is clean regarding colors
+  for color in BLUE RED GREEN CYAN WHITE ; unset $color
+
 # source another config file if present {{{
   if [ -r /etc/zsh/zshrc.local ]; then
    source /etc/zsh/zshrc.local