Added aliases S, s, top10 and function weather()
authorMichael Prokop <mika@grml.org>
Tue, 17 Jul 2007 13:50:48 +0000 (15:50 +0200)
committerMichael Prokop <mika@grml.org>
Tue, 17 Jul 2007 13:50:48 +0000 (15:50 +0200)
debian/changelog
etc/skel/.zshrc
etc/zsh/zshrc

index 14f9cdd..c2d2864 100644 (file)
@@ -1,3 +1,16 @@
+grml-etc-core (0.3.17) unstable; urgency=low
+
+  The 'Man, what a lazy folk'-release
+  * /etc/skel/.zshrc:
+    - added function weather() to retrieve weather information on
+      the console
+  * /etc/zsh/zshrc:
+    - added alias S for screen
+    - alias s for ssh
+    - added alias top10 to get the top 10 shell commands from the history
+
+ -- Michael Prokop <mika@grml.org>  Tue, 17 Jul 2007 15:48:48 +0200
+
 grml-etc-core (0.3.16) unstable; urgency=low
 
   * /etc/zsh/zshrc: dchange() - restore old behaviour with
index 1a51fa1..070f831 100644 (file)
      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"° Celcius / " $2"° 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 {{{
index 53e5177..17c4721 100644 (file)
@@ -11,8 +11,8 @@
 #
 # Global Order: zshenv, zprofile, zshrc, zlogin
 ################################################################################
-#
-# zsh-refcard-tag documentation:
+
+# zsh-refcard-tag documentation: {{{
 #   You may notice strange looking comments in the zshrc (and ~/.zshrc as
 #   well). These are there for a purpose. grml's zsh-refcard can now be
 #   automatically generated from the contents of the actual configuration
@@ -20,7 +20,7 @@
 #   and what lines of code to take into account (and for what purpose).
 #
 # Here is what they mean:
-#{{{
+#
 # List of tags (comment types) used:
 #   #a#     Next line contains an important alias, that should
 #           be included in the grml-zsh-refcard.
@@ -839,6 +839,13 @@ ${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< %# "
 # I like clean prompt, so provide simple way to get that
   alias 0 &>/dev/null || functions 0 &>/dev/null || alias 0='return 0'
 
+# for really lazy people like mika:
+  type S &>/dev/null || alias S='screen'
+  type s &>/dev/null || alias s='ssh'
+
+# get top 10 shell commands:
+  alias top10='print -l ? ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
+
 # truecrypt; use e.g. via 'truec /dev/ice /mnt/ice' or 'truec -i'
   if [ -x $(which truecrypt) ] ; then
      if isutfenv ; then