Last active
December 21, 2015 16:29
-
-
Save yfyf/6334276 to your computer and use it in GitHub Desktop.
.bashrc hack for preserving shell directory in newly opened shells
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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