Skip to content

Instantly share code, notes, and snippets.

@costa
Created October 14, 2009 13:45
Show Gist options
  • Save costa/210085 to your computer and use it in GitHub Desktop.
Save costa/210085 to your computer and use it in GitHub Desktop.
petter cd
# Unfortunately, some tools, e.g. rvm (https://beginrescueend.com/), hook to cd, but not to pushd/popd. Not a problem!
pushd() { builtin pushd "$@" && cd .; }
popd() { builtin popd "$@" && cd .; }
pd() {
if [ "$#" -eq "0" ]
then if popd &> /dev/null && pwd > ~/.pd; then :; else pd "`cat ~/.pd`"; fi
else pushd "$1" &> /dev/null && pwd > ~/.pd
fi
}
mpd() { mkdir -p "$@" && pd "${!#}"; } # TODO find out about that last argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment