1cfd813f796e4472575daf4b51cd816bacc833e0

Author
rylwin <ryan@thewinograds.com>
Committer
rylwin <ryan@thewinograds.com>
Date

Message

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.

Diff

 1diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh
 2index 190bc279d505cc9c985023f10a12ee694dbd3067..4903616e3671d9ce4cbfc5a23336b90e3adf9a77 100644
 3--- a/plugins/last-working-dir/last-working-dir.plugin.zsh
 4+++ b/plugins/last-working-dir/last-working-dir.plugin.zsh
 5@@ -9,7 +9,8 @@ local cache_file="$ZSH/cache/last-working-dir"
 6 
 7 # Updates the last directory once directory is changed.
 8 function chpwd() {
 9-	echo "$PWD" > "$cache_file"
10+        # Use >! in case noclobber is set to avoid "file exists" error
11+	echo "$PWD" >! "$cache_file"
12 }
13 
14 # Changes directory to the last working directory.