From 90c21a27bb648a3c592cc7d2ea18a944177c8f83 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 20 Aug 2016 01:26:38 +1200 Subject: Move oldpwd.sh functionality into profile --- sh/profile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sh/profile') diff --git a/sh/profile b/sh/profile index 7266d64e..b2889295 100644 --- a/sh/profile +++ b/sh/profile @@ -3,11 +3,11 @@ if [ -d "$HOME"/.local/bin ] ; then PATH=$HOME/.local/bin:$PATH fi -# Load all supplementary scripts in ~/.profile.d -for sh in "$HOME"/.profile.d/*.sh ; do - [ -e "$sh" ] && . "$sh" -done -unset -v sh +# If we can read ~/.oldpwd, make its contents our OLDPWD +if [ -r "$HOME"/.oldpwd ] ; then + IFS= read -r OLDPWD < "$HOME"/.oldpwd + export OLDPWD +fi # Trap on exit to run ~/.logout if it exists logout_trap() { @@ -25,6 +25,12 @@ for sig in EXIT HUP INT TERM ; do done unset -v sig +# Load all supplementary scripts in ~/.profile.d +for sh in "$HOME"/.profile.d/*.sh ; do + [ -e "$sh" ] && . "$sh" +done +unset -v sh + # If ENV is unset after running those scripts and ~/.shrc exists, set it as ENV if [ -z "$ENV" ] && [ -f "$HOME"/.shrc ] ; then ENV=$HOME/.shrc -- cgit v1.2.3