Below is the file '.zshfunctions' from this revision. You can also download the file.


#
# .zshfunctions - user defined functions. read in by .zshrc
#

psg ()
{
	if [[ ! $# = 1 ]]; then
		echo -e "psg <regex>\n\tSearch for processes matching <regex>"
		return
	fi
	ps auxwww | egrep $1;
}

psk ()
{
	if [[ ! $# = 2 ]]; then
		echo -e "psk <signal> <regex>\n\tKill processes matching <regex>"
		return
	fi
	kill $1 `psg $2 | awk '{print $2}'`
}

zsh-reload ()
{
	source "$HOME/.zshenv"
	source "$HOME/.zshprofile"
	source "$HOME/.zshrc"
}

zsh-update ()
{
	cd && svn update && zsh-reload
}

intelcc()
{
	. /opt/intel/idb/9.0/bin/idbvars.sh
	. /opt/intel/cc/9.0/bin/iccvars.sh
}

sfcvs()
{
	export CVSROOT=:pserver:anonymous@cvs.arcem.sourceforge.net:/cvsroot/arcem
}

ucccvs()
{
	export CVS_RSH=ssh
	export CVSROOT=mussel.ucc.gu.uwa.edu.au:/home/other/cvs
}

prettyprinttxt()
{
	enscript -2 -M A4 -B -j -r $*
}

ssu()
{
	NONROOTHOME=$HOME
	su - root -c "HOME=$NONROOTHOME;export HOME;exec /usr/bin/zsh"
}

startagent()
{
	ssh-agent > ~/.main-agent
	chmod 600 ~/.main-agent
	source ~/.main-agent
}

# takes two arguments, first is the name of the shell variable
# second is a directory name. if dir exists it is appended to the
# variable
append_if_dir ()
{
	if [ ! $# = 2 ]; then return; fi
	v="$1" d="$2" vs='$'"$1"
	if [[ -d "$d" ]]; then
		if [[ -z "${(e)vs}" ]]; then
			export $v="${d}"
		else
			export $v="${(e)vs}:${d}"
		fi
	fi
}

prepend_if_dir ()
{
	if [ ! $# = 2 ]; then return; fi
	v="$1" d="$2" vs='$'"$1"
	if [[ -d "$d" ]]; then
		if [[ -z "${(e)vs}" ]]; then
			export $v="${d}"
		else
			export $v="${d}:${(e)vs}"
		fi
	fi
}

histoff()
{
       HISTFILE=/dev/null
}

sgrep()
{
	find .  -type f -and -not -wholename '*/.svn/*' -exec grep "$*" {} /dev/null \;
}