From 5f1c44d1b74edf836bb489bb96a409c9aeb402ad Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 Apr 2015 16:09:04 +1200 Subject: Keep OLDPWD between logins --- bash/bash_logout | 3 +++ sh/profile.d/oldpwd.sh | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 sh/profile.d/oldpwd.sh diff --git a/bash/bash_logout b/bash/bash_logout index 29264c78..6f539b04 100644 --- a/bash/bash_logout +++ b/bash/bash_logout @@ -8,3 +8,6 @@ if ((SHLVL == 1)) ; then clear_console -q 2>/dev/null fi +# Write PWD to a file if set +printf '%s\n' "$PWD" > "${OLDPWD_FILE:-$HOME/.oldpwd}" + diff --git a/sh/profile.d/oldpwd.sh b/sh/profile.d/oldpwd.sh new file mode 100644 index 00000000..96786338 --- /dev/null +++ b/sh/profile.d/oldpwd.sh @@ -0,0 +1,6 @@ +# If we can read ~/.oldpwd, make its contents our OLDPWD +if [ -r "${OLDPWD_FILE:-$HOME/.oldpwd}" ] ; then + read -r OLDPWD < "${OLDPWD_FILE:-$HOME/.oldpwd}" + export OLDPWD +fi + -- cgit v1.2.3