Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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