Skip to content

Instantly share code, notes, and snippets.

@casualjim
Created February 10, 2012 12:52
Show Gist options
  • Save casualjim/1789516 to your computer and use it in GitHub Desktop.
Save casualjim/1789516 to your computer and use it in GitHub Desktop.
Source a file in a directory hierarchy if found in zsh
function chpwd() {
moj_root=$(pwd -P 2>/dev/null || command pwd)
while [ ! -e "$moj_root/.mojolly-env" ]; do
moj_root=${moj_root%/*}
if [ "$moj_root" = "" ]; then break; fi
done
if [ -r "$moj_root/.mojolly-env" ]; then source "$moj_root/mojolly-env"; fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment