Created
February 15, 2013 21:48
-
-
Save mikbe/4963820 to your computer and use it in GitHub Desktop.
A friendlier change directory for Bash and OS X.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change to a directory given a full or partial name | |
# You don't have to wrap directory names in quotes either | |
function chd() { | |
friendlyChgDirOptions | |
if [ -n "$1" ]; then | |
if [ -n "`ls "$@"* 2>/dev/null`" ]; then | |
cd "$1"* | |
else | |
echo "-bash: chd: "$1": No directory found from partial name" | |
fi | |
fi | |
} | |
function friendlyChgDirOptions() { | |
shopt -s cdspell | |
shopt -s nocaseglob | |
} | |
function dev() { | |
cd "$HOME/development" | |
chd "$@" | |
} | |
function sites() { | |
cd "$HOME/sites" | |
chd "$@" | |
} | |
function home() { | |
cd "$HOME" | |
chd "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment