# 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: Mon Sep 18 18:54:28 CEST 2006 [mika]
+# Latest change: Don Okt 26 00:50:18 CEST 2006 [mika]
################################################################################
# source ~/.zshrc.global {{{
# 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
fi
fi
}
+# }}}
+
+# mercurial related stuff {{{
+ if type -p hg >/dev/null 2>&1 ; then
+ # gnu like diff for mercurial
+ # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
+ hgdi() {
+ for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
+ }
+
+ # diffstat for specific version of mercurial
+ # hgstat => display diffstat between last revision and tip
+ # hgstat 1234 => display diffstat between revision 1234 and tip
+ hgstat() {
+ [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
+ }
+
+ # 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 mercurial"
+ make local
+ echo "Setting \$PATH to $PWD:\$PATH..."
+ export PATH="$PWD:$PATH"
+ else
+ echo "Downloading mercurial via hg"
+ hg clone http://selenic.com/repo/hg mercurial-tree
+ cd mercurial-tree
+ echo "Building mercurial"
+ make local
+ echo "Setting \$PATH to $PWD:\$PATH..."
+ export PATH="$PWD:$PATH"
+ echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
+ # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
+ # export PYTHONPATH=${HOME}/lib/python
+ fi
+ }
+
+ fi # end of check whether we have the 'hg'-executable
+ # get and install current mercurial snapshot in $HOME
+ gethgsnap() {
+ setopt local_options
+ setopt errreturn
+ if [ -f mercurial-snapshot.tar.gz ] ; then
+ echo "mercurial-snapshot.tar.gz exists already, skipping download."
+ else
+ echo "Downloading mercurial snapshot"
+ wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
+ fi
+ echo "Unpacking mercurial-snapshot.tar.gz"
+ tar zxf mercurial-snapshot.tar.gz
+ cd mercurial-snapshot/
+ echo "Installing required build-dependencies"
+ $SUDO apt-get update
+ $SUDO apt-get install python2.4-dev
+ echo "Building mercurial"
+ make local
+ echo "Setting \$PATH to $PWD:\$PATH..."
+ export PATH="$PWD:$PATH"
+ echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
+ }
# }}}
# some useful commands often hard to remember - let's grep for them {{{