Skip to content

Instantly share code, notes, and snippets.

@rcmdnk
Last active December 16, 2015 01:39
Show Gist options
  • Save rcmdnk/5356817 to your computer and use it in GitHub Desktop.
Save rcmdnk/5356817 to your computer and use it in GitHub Desktop.
function cd {
if [ $# = 0 ];then
command cd
elif [ "$1" = "-" ];then
local opwd=$OLDPWD
pushd . >/dev/null
command cd $opwd
elif [ -f "$1" ];then
pushd . >/dev/null
command cd $(dirname "$@")
else
pushd . >/dev/null
command cd "$@"
fi
}
alias bd="popd >/dev/null"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment