Skip to content

Instantly share code, notes, and snippets.

@yfyf
Last active December 21, 2015 16:29
Show Gist options
  • Save yfyf/6334276 to your computer and use it in GitHub Desktop.
Save yfyf/6334276 to your computer and use it in GitHub Desktop.
.bashrc hack for preserving shell directory in newly opened shells
# there's probably a nicer way to do this, but anyway:
# path where to hold the last cwd
SUPER_CWD_FILE=/tmp/scwd
# store the cwd on each command
export PROMPT_COMMAND="pwd > $SUPER_CWD_FILE; $PROMPT_COMMAND"
# restore the cwd when starting a new shell
[ -r $SUPER_CWD_FILE ] && cd `cat $SUPER_CWD_FILE`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment