zshrc: Fixing a bug in urlencode()
[grml-etc-core.git] / etc / skel / .zshrc
index 3d008a1..d7b2840 100644 (file)
@@ -3,7 +3,6 @@
 # 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: Sat Jan 26 11:55:04 CET 2008
 ################################################################################
 
 # source ~/.zshrc.global {{{
@@ -46,7 +45,7 @@ check_com compinit || { autoload -U compinit && compinit }
 check_com isgrmlsmall || function isgrmlsmall () { return 1 }
 # }}}
 
-## variables {{{
+# variables {{{
 
 # do you want grmlsmall-specific adjustments?
 GRMLSMALL_SPECIFIC=1
@@ -74,7 +73,7 @@ fi
 [[ -f /usr/share/classpath/glibj.zip ]] && export JIKESPATH=/usr/share/classpath/glibj.zip
 # }}}
 
-## set options {{{
+# set options {{{
 
 # Allow comments even in interactive shells i. e.
 # $ uname # This command prints system informations
@@ -114,7 +113,7 @@ fi
 #  alias -g V='| vim -'
 # }}}
 
-## aliases {{{
+# aliases {{{
 
 # Xterm resizing-fu.
 # Based on http://svn.kitenet.net/trunk/home-full/.zshrc?rev=11710&view=log (by Joey Hess)
@@ -220,6 +219,9 @@ alias fblinks='links2 -driver fb'
 alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
 alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
 
+# simple webserver
+check_com -c python && alias http="python -m SimpleHTTPServer"
+
 # Use 'g' instead of 'git':
 check_com g || alias g='git'
 
@@ -253,13 +255,13 @@ if check_com isutfenv && check_com luit ; then
 fi
 # }}}
 
-## useful functions {{{
+# useful functions {{{
 
 # searching
 #f4# Search for newspostings from authors
 agoogle() { ${=BROWSER} "http://groups.google.com/groups?as_uauthors=$*" ; }
-#f4# Search Debian Bug Tracking System by BugID in mbox format
-debbug()  { 
+#f4# Search Debian Bug Tracking System
+debbug()  {
     setopt localoptions extendedglob
     if [[ $# -eq 1 ]]; then
         case "$1" in
@@ -278,7 +280,7 @@ debbug()  {
         return 1
     fi
 }
-#f4# Search Debian Bug Tracking System
+#f4# Search Debian Bug Tracking System in mbox format
 debbugm() { bts show --mbox $1 } # provide bugnummer as "$1"
 #f4# Search DMOZ
 dmoz()    { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} }
@@ -360,6 +362,19 @@ ytdl() {
     fi
 }
 
+# Function Usage: uopen $URL/$file
+#f5# Download a file and display it locally
+uopen() {
+    if ! [[ -n "$1" ]] ; then
+        print "Usage: uopen \$URL/\$file">&2
+        return 1
+    else
+        FILE=$1
+        MIME=$(curl --head $FILE | grep Content-Type | cut -d ' ' -f 2 | cut -d\; -f 1)
+        MIME=${MIME%$'\r'}
+        curl $FILE | see ${MIME}:-
+    fi
+}
 
 # Function Usage: doc packagename
 #f5# \kbd{cd} to /usr/share/doc/\textit{package}
@@ -599,6 +614,7 @@ show-archive() {
             *.tgz)         tar -ztf $1 ;;
             *.zip)         unzip -l $1 ;;
             *.bz2)         bzless $1 ;;
+            *.deb)         dpkg-deb --fsys-tarfile $1 | tar -tf - -- ;;
             *)             echo "'$1' Error. Please go away" ;;
         esac
     else
@@ -622,6 +638,22 @@ readme() {
     fi
 }
 
+# function ansi-colors()
+#f5# Display ANSI colors
+ansi-colors() {
+    typeset esc="\033[" line1 line2
+    echo " _ _ _40 _ _ _41_ _ _ _42 _ _ 43_ _ _ 44_ _ _45 _ _ _ 46_ _ _ 47_ _ _ 49_ _"
+    for fore in 30 31 32 33 34 35 36 37; do
+        line1="$fore "
+        line2="   "
+        for back in 40 41 42 43 44 45 46 47 49; do
+            line1="${line1}${esc}${back};${fore}m Normal ${esc}0m"
+            line2="${line2}${esc}${back};${fore};1m Bold   ${esc}0m"
+        done
+        echo -e "$line1\n$line2"
+    done
+}
+
 # suidfind() { ls -latg $path | grep '^...s' }
 #f5# Find all files in \$PATH with setuid bit set
 suidfind() { ls -latg $path/*(sN) }
@@ -787,7 +819,7 @@ ogg2mp3_192() {
 urlencode() {
     setopt localoptions extendedglob
     input=( ${(s::)1} )
-    print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
+    print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%${(l:2::0:)$(([##16]#match))}}
 }
 
 #f5# Install x-lite (VoIP software)
@@ -832,11 +864,11 @@ getskypebeta() {
 getgizmo() {
     setopt local_options
     setopt errreturn
-    echo "gconf2-common and libgconf2-4 have to be available. Installing therefor."
+    echo "libgtk2.0-0, gconf2, libstdc++6, libasound2 and zlib1g have to be available. Installing."
     $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 apt-get install libgtk2.0-0 gconf2 libstdc++6 libasound2 zlib1g
+    wget "$(lynx --dump http://gizmo5.com/pc/download/linux/ | awk '/libstdc\+\+6.*\.deb/ {print $2}')"
+    $SUDO dpkg -i gizmo-project*.deb && echo "gizmo installed."
 }
 
 #f5# Get and run AIR (Automated Image and Restore)
@@ -1046,6 +1078,30 @@ zurl() {
         | sed 's/value=//;s/"//g'
 }
 
+#f2# Print a specific line of file(s).
+linenr () {
+# {{{
+    if [ $# -lt 2 ] ; then
+       print "Usage: linenr <number>[,<number>] <file>" ; return 1
+    elif [ $# -eq 2 ] ; then
+         local number=$1
+         local file=$2
+         command ed -s $file <<< "${number}n"
+    else
+         local number=$1
+         shift
+         for file in "$@" ; do
+             if [ ! -d $file ] ; then
+                echo "${file}:"
+                command ed -s $file <<< "${number}n" 2> /dev/null
+             else
+                continue
+             fi
+         done | less
+    fi
+# }}}
+}
+
 #f2# Find history events by search pattern and list them by date.
 whatwhen()  {
 # {{{
@@ -1293,9 +1349,6 @@ gethgsnap() {
 # modifications in ~/.zshrc.local
 xsource "${HOME}/.zshrc.local"
 
-# ...and remove utility functions again.
-xunfunction
-
 # }}}
 
 ### doc strings for external functions from files