Skip to content

Instantly share code, notes, and snippets.

@magoon
Created August 17, 2013 19:11
Show Gist options
  • Save magoon/6258317 to your computer and use it in GitHub Desktop.
Save magoon/6258317 to your computer and use it in GitHub Desktop.
Bash alias to change dir to a subdirectory containing a known file
#
# Usage: cdf style.css
#
# Add to your ~/.bash_profile and then source ~/.bash_profile
#
# If you were in ~/somedir, this could cd ~/somedir/docroot/styles/ if it contained style.css
#
alias cdf=cdfilefunc
cdfilefunc()
{
DIRNAME=`find . -name "$1" -exec dirname {} \;`
cd $DIRNAME
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment