Support LESS_TERMCAP_*
[grml-etc-core.git] / etc / skel / .zshrc
index 1a51fa1..9c7fb60 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: Don Mai 31 17:19:00 CEST 2007 [mika]
+# Latest change: Mon Jul 23 11:40:12 CEST 2007 [mika]
 ################################################################################
 
 # source ~/.zshrc.global {{{
   alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
   alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
 
-# use colors when browsing man pages (if not using pinfo or PAGER=most)
-  [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
+# use colors when browsing man pages, but only if not using LESS_TERMCAP_* from /etc/zsh/zshenv:
+  if [ -z "$LESS_TERMCAP_md" ] ; then
+     [ -d ~/.terminfo/ ] && alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
+  fi
 
 # check whether Debian's package management (dpkg) is running
   if type salias &>/dev/null ; then
      if [ -x $(which mrxvt) ] ; then
         isutfenv && [ -n "$LANG" ] && alias mrxvt="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} mrxvt"
      fi
-   
+
      if [ -x $(which aterm) ] ; then
         isutfenv && [ -n "$LANG" ] && alias aterm="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} aterm"
      fi
-   
+
      if [ -x $(which centericq) ] ; then
         isutfenv && [ -n "$LANG" ] && alias centericq="LANG=${LANG/(#b)(*)[.@]*/$match[1].iso885915} centericq"
      fi
     fi
   }
 
+# retrieve weather information on the console
+# Usage example: 'weather LOWG'
+  weather () {
+   [ -n "$1" ] || {
+           print 'Usage: weather <station_id>' >&2
+           return 1
+   }
+
+   local PLACE="${1:u}"
+   local FILE="$HOME/.weather/$PLACE"
+   local LOG="$HOME/.weather/log"
+
+   [ -d $HOME/.weather ] || {
+           print -n "Creating $HOME/.weather: "
+           mkdir $HOME/.weather
+           print 'done'
+   }
+
+   print "Retrieving information for ${PLACE}:"
+   print
+   wget -T 10 --no-verbose --output-file=$LOG --output-document=$FILE --timestamping http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT
+
+   if [[ $? = 0 ]] ; then
+           if [ -n "$VERBOSE" ] ; then
+                   cat $FILE
+           else
+                   DATE=$(grep 'UTC' $FILE | sed 's#.* /##')
+                   TEMPERATURE=$(awk '/Temperature/ { print $4" degree Celcius / " $2" degree Fahrenheit" }' $FILE| tr -d '(')
+                   echo "date: $DATE"
+                   echo "temp:  $TEMPERATURE"
+           fi
+   else
+           print "There was an error retrieving the weather information for $PLACE" >&2
+           cat $LOG
+           return 1
+   fi
+  }
+
+
 # }}}
 
 # mercurial related stuff {{{