-
-
Save kafene/6246945 to your computer and use it in GitHub Desktop.
silent pushd (aliased to cd)
This file contains 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
function cd { | |
if (("$#" > 0)); then | |
if [ "$1" == "-" ]; then | |
builtin popd >/dev/null | |
elif [ "$1" == "--" ]; then | |
dirs -v | |
return $? | |
elif [ "$1" == "." ]; then | |
# break out of symlinked dir (cd into realpath) | |
builtin pushd "`pwd -P`" >/dev/null | |
else | |
builtin pushd "$@" >/dev/null | |
fi | |
else | |
builtin cd "$HOME" >/dev/null | |
fi | |
[ $# -ne 0 ] && builtin cd "$1" | |
pwd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment