2 # Keeps track of the last used working directory and automatically jumps
3 # into it for new shells.
5 # Flag indicating if we've previously jumped to last directory.
6 typeset
-g ZSH_LAST_WORKING_DIRECTORY
8 local cache_file
="$ZSH/cache/last-working-dir"
10 # Updates the last directory once directory is changed.
12 echo "$PWD" > "$cache_file"
15 # Changes directory to the last working directory.
17 [[ ! -r "$cache_file" ]] || cd `cat "$cache_file"`
20 # Automatically jump to last working directory unless this isn't the first time
21 # this plugin has been loaded.
22 if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then
23 lwd
2>/dev
/null
&& ZSH_LAST_WORKING_DIRECTORY
=1 || true