summaryrefslogtreecommitdiff
path: root/Completion/Base/Completer
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base/Completer')
-rw-r--r--Completion/Base/Completer/_expand2
-rw-r--r--Completion/Base/Completer/_external_pwds39
-rw-r--r--Completion/Base/Completer/_history7
3 files changed, 46 insertions, 2 deletions
diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index e52144cb7..3c76e1328 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -87,7 +87,7 @@ if [[ "$force" = *s* ]] ||
setopt aliases
eval 'exp=( ${${(e)exp//\\[
-]/ }//(#b)([
+]/ }//(#b)([ \\
])/\\$match[1]} )' 2>/dev/null
setopt NO_aliases
else
diff --git a/Completion/Base/Completer/_external_pwds b/Completion/Base/Completer/_external_pwds
new file mode 100644
index 000000000..4ad50f02b
--- /dev/null
+++ b/Completion/Base/Completer/_external_pwds
@@ -0,0 +1,39 @@
+#autoload
+
+# Completes current directories of other zsh processes
+# this is intended to be used via _generic bound to a
+# different key. Note that pattern matching is enabled.
+
+local -a expl
+local -au dirs
+
+# undo work _main_complete did to remove the tilde
+PREFIX="$IPREFIX$PREFIX"
+IPREFIX=
+SUFFIX="$SUFFIX$ISUFFIX"
+ISUFFIX=
+
+[[ -o magicequalsubst ]] && compset -P '*='
+
+case $OSTYPE in
+ solaris*)
+ dirs=(
+ ${(M)${${(f)"$(pgrep -U $UID -x zsh|xargs pwdx 2>/dev/null)"}:#$$:*}%%/*}
+ )
+ ;;
+ linux*)
+ dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:A) )
+ dirs=( $^dirs(N^@) )
+ ;;
+ *)
+ if (( $+commands[lsof] )); then
+ dirs=( ${${${(M)${(f)"$(lsof -a -u $EUID -c zsh -p \^$$ -d cwd -F n -w
+ 2>/dev/null)"}:#n*}#?}%% \(*} )
+ fi
+ ;;
+esac
+dirs=( ${(D)dirs} )
+
+compstate[pattern_match]='*'
+_wanted directories expl 'current directory from other shell' \
+ compadd -M "r:|/=* r:|=*" -f -a dirs
diff --git a/Completion/Base/Completer/_history b/Completion/Base/Completer/_history
index 63878ac1c..cd69ca17b 100644
--- a/Completion/Base/Completer/_history
+++ b/Completion/Base/Completer/_history
@@ -51,9 +51,14 @@ ISUFFIX=
# We skip the first element of historywords so the current word doesn't
# interfere with the completion
+local -a hslice
while [[ $compstate[nmatches] -eq 0 && beg -lt max ]]; do
+ if [[ -n $compstate[quote] ]]
+ then hslice=( ${(Q)historywords[beg,beg+slice]} )
+ else hslice=( ${historywords[beg,beg+slice]} )
+ fi
_wanted "$opt" history-words expl 'history word' \
- compadd -Q -a 'historywords[beg,beg+slice]'
+ compadd -Q -a hslice
(( beg+=slice ))
done