summaryrefslogtreecommitdiff
path: root/plugins/last-working-dir/last-working-dir.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/last-working-dir/last-working-dir.plugin.zsh')
-rw-r--r--plugins/last-working-dir/last-working-dir.plugin.zsh9
1 files changed, 5 insertions, 4 deletions
diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh
index bc36c80db..c458464ce 100644
--- a/plugins/last-working-dir/last-working-dir.plugin.zsh
+++ b/plugins/last-working-dir/last-working-dir.plugin.zsh
@@ -4,18 +4,19 @@
# Flag indicating if we've previously jumped to last directory.
typeset -g ZSH_LAST_WORKING_DIRECTORY
-mkdir -p "$ZSH/cache"
-local cache_file="$ZSH/cache/last-working-dir"
+mkdir -p $ZSH_CACHE_DIR
+cache_file="$ZSH_CACHE_DIR/last-working-dir"
# Updates the last directory once directory is changed.
-function chpwd() {
+chpwd_functions+=(chpwd_last_working_dir)
+function chpwd_last_working_dir() {
# Use >| in case noclobber is set to avoid "file exists" error
pwd >| "$cache_file"
}
# Changes directory to the last working directory.
function lwd() {
- [[ ! -r "$cache_file" ]] || cd `cat "$cache_file"`
+ [[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`"
}
# Automatically jump to last working directory unless this isn't the first time