summaryrefslogtreecommitdiff
path: root/plugins/last-working-dir
diff options
context:
space:
mode:
authorrylwin <ryan@thewinograds.com>2013-03-13 22:48:28 -0500
committerrylwin <ryan@thewinograds.com>2013-03-13 22:48:28 -0500
commit1cfd813f796e4472575daf4b51cd816bacc833e0 (patch)
tree96c64e6290c9ccd8e9899a5907302cc8ea298c46 /plugins/last-working-dir
parent0ab0e67ecfc52b4779b700149a9c51feeb05318e (diff)
downloadzsh-1cfd813f796e4472575daf4b51cd816bacc833e0.tar.gz
zsh-1cfd813f796e4472575daf4b51cd816bacc833e0.tar.bz2
zsh-1cfd813f796e4472575daf4b51cd816bacc833e0.zip
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.
Diffstat (limited to 'plugins/last-working-dir')
-rw-r--r--plugins/last-working-dir/last-working-dir.plugin.zsh3
1 files changed, 2 insertions, 1 deletions
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.