From 1cfd813f796e4472575daf4b51cd816bacc833e0 Mon Sep 17 00:00:00 2001 From: rylwin Date: Wed, 13 Mar 2013 22:48:28 -0500 Subject: [PATCH] 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 190bc279d..4903616e3 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.