Created
April 19, 2020 21:07
-
-
Save ZebTheWizard/8e378a67a139737e5c02cd535599e584 to your computer and use it in GitHub Desktop.
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
DEFAULT_DIRECTORY="$HOME" | |
LAST_CD_DIRECTORY=$(cat $HOME/.last_cd_directory 2>/dev/null) | |
CURRENT_SHELL="$0" | |
function go_to_default_or_previous | |
{ | |
if (( $(ps aux | grep $CURRENT_SHELL | grep -v $$ | wc -l) > 0)) | |
then | |
export DEFAULT_DIRECTORY="$LAST_CD_DIRECTORY" | |
fi | |
} | |
function cd | |
{ | |
builtin cd "$1" && echo "$1" > $HOME/.last_cd_directory; | |
} | |
go_to_default_or_previous | |
cd $DEFAULT_DIRECTORY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment