Skip to content

Instantly share code, notes, and snippets.

@mhoffman
Created July 8, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhoffman/c9c9c646802ce2a1fc0f999e07a8f611 to your computer and use it in GitHub Desktop.
Save mhoffman/c9c9c646802ce2a1fc0f999e07a8f611 to your computer and use it in GitHub Desktop.
# always use pushd/popd by default
# and if directory turns out to be a file, we open it with vi :-)
function cd() {
if [ "$#" = "0" ]
then
pushd ${HOME} > /dev/null
elif [ -f "${1}" ]
then
${EDITOR} ${1}
else
pushd "$1" > /dev/null
fi
}
# bd 5 goes 5 directories back in history
function bd(){
if [ "$#" = "0" ]
then
popd > /dev/null
else
for i in $(seq ${1})
do
popd > /dev/null
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment