Mercurial > dotfiles
view .shell.d/00.path_manipulation.sh @ 142:daceba28ace4
hgignore: everyone stand back! I know regular expressions!
This fixes ignores so that certain subdirectories will show me untracked files.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 17 Sep 2009 10:26:25 -0500 |
parents | de6d0a9a7e3f |
children | 7dfb7799567f |
line wrap: on
line source
# Functions for manipulating $PATH. Split out so I can use them in .zshenv if I want. function insert_path_element() { insert_element_into_var $1 PATH } function remove_path_element() { remove_path_element $1 PATH } function insert_element_into_var () { eval varcontents=\$"$2" eval varname="$2" newcomp="$1" if echo "$varcontents" | grep "$newcomp:" >> /dev/null; then true elif [[ "$varcontents" == "" ]] ; then export $varname="$newcomp" else export $varname="$newcomp:$varcontents" fi } function remove_element_from_var() { eval varcontents=\$"$2" eval varname="$2" newcomp="$1" if echo "$varcontents" | grep "$newcomp:" >> /dev/null; then export $varname="`echo $varcontents | sed s%$newcomp:%%`" elif [[ "$varcontents" == "$newcomp" ]] ; then unset $varname else echo $1 not in $varname fi }