From 1cfd813f796e4472575daf4b51cd816bacc833e0 Mon Sep 17 00:00:00 2001 From: rylwin Date: Wed, 13 Mar 2013 22:48:28 -0500 Subject: [PATCH 1/2] last-working-dir: Use >! to overwrite $cache_file Use ">!" to overwrite $cache_file in case noclobber is set. When noclobber is set, zsh will not allow the use of ">" to overwrite the contents of a file. Instead, it displays a "file exists" error. By using ">!" instead, we tell zsh to overwrite the file without complaining. --- plugins/last-working-dir/last-working-dir.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 190bc279..4903616e 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -9,7 +9,8 @@ local cache_file="$ZSH/cache/last-working-dir" # Updates the last directory once directory is changed. function chpwd() { - echo "$PWD" > "$cache_file" + # Use >! in case noclobber is set to avoid "file exists" error + echo "$PWD" >! "$cache_file" } # Changes directory to the last working directory. From 4c8bba57acb0f64edde89321d5d6cbc3a5226cac Mon Sep 17 00:00:00 2001 From: Ryan Winograd Date: Wed, 13 Mar 2013 22:51:12 -0500 Subject: [PATCH 2/2] Fix whitespace That's what I get for using GitHub text editor and not checking tabs. --- plugins/last-working-dir/last-working-dir.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 4903616e..ccf0f5b2 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -9,7 +9,7 @@ local cache_file="$ZSH/cache/last-working-dir" # Updates the last directory once directory is changed. function chpwd() { - # Use >! in case noclobber is set to avoid "file exists" error + # Use >! in case noclobber is set to avoid "file exists" error echo "$PWD" >! "$cache_file" }