From 18effd77db1156c11848bd3bfadd8fa63c747516 Mon Sep 17 00:00:00 2001 From: Xiao Fan Date: Fri, 11 May 2018 07:28:02 -0700 Subject: [PATCH] last-working-dir: disable chpwd_last_working_dir in subshells (#6817) --- plugins/last-working-dir/last-working-dir.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index e882b288..53bb19e4 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -4,8 +4,10 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY # Updates the last directory once directory is changed chpwd_functions+=(chpwd_last_working_dir) chpwd_last_working_dir() { - local cache_file="$ZSH_CACHE_DIR/last-working-dir" - pwd >| "$cache_file" + if [ "$ZSH_SUBSHELL" = 0 ]; then + local cache_file="$ZSH_CACHE_DIR/last-working-dir" + pwd >| "$cache_file" + fi } # Changes directory to the last working directory