Skip to content

Instantly share code, notes, and snippets.

@christos
Forked from defunkt/gist:132456
Created July 1, 2010 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christos/459765 to your computer and use it in GitHub Desktop.
Save christos/459765 to your computer and use it in GitHub Desktop.
Bash snippet to open new shells in most recently visited dir.
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
\cd
else
\cd "$1"
fi
pwd > ~/.cdpath
}
alias cd="pathed_cd"
if [ -f ~/.cdpath ]; then
cd $(cat ~/.cdpath)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment