about summary refs log tree commit diff
path: root/Functions/Chpwd/chpwd_recent_add
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-07-09 14:47:48 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-07-09 14:47:48 +0000
commit5da6530d831ea8a00943b39359d535ea59996894 (patch)
tree2a4fcd827214fa4fd2a8d172341a07cb8b76cda0 /Functions/Chpwd/chpwd_recent_add
parent924f40b772d7c222ffe8db502fb88cc897fd9902 (diff)
downloadzsh-5da6530d831ea8a00943b39359d535ea59996894.tar.gz
zsh-5da6530d831ea8a00943b39359d535ea59996894.tar.xz
zsh-5da6530d831ea8a00943b39359d535ea59996894.zip
28065 plus unposted zsh.mdd:
add cdr and related functions and docs
Diffstat (limited to 'Functions/Chpwd/chpwd_recent_add')
-rw-r--r--Functions/Chpwd/chpwd_recent_add24
1 files changed, 24 insertions, 0 deletions
diff --git a/Functions/Chpwd/chpwd_recent_add b/Functions/Chpwd/chpwd_recent_add
new file mode 100644
index 000000000..49ec8d1c6
--- /dev/null
+++ b/Functions/Chpwd/chpwd_recent_add
@@ -0,0 +1,24 @@
+# Helper for chpwd_recent_dirs.
+# Add a directory to the reply array unless we're skipping it.
+# If skipping, return non-zero status.
+
+local pat
+local add=$1
+local -a prune patterns
+
+zstyle -a ':chpwd:' recent-dirs-prune prune
+if (( ${#prune} )); then
+  patterns=(${${prune:#^pattern:*}##pattern:})
+fi
+
+for pat in $patterns; do
+  if [[ $add =~ ${~pat} ]]; then
+    return 1
+  fi
+done
+
+if [[ ${prune[(I)parent]} -ne 0 && $add = $reply[1]/* ]]; then
+  # replace
+  reply=($reply[2,-1])
+fi
+reply=($add $reply)