Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to add a 'non-escaped' tilde to the completion list



Death Jester wrote:
> The binding however was not the problem, but the type of
> completion.

Using menu completion is an improvement. You'll find that this now works
on an empty word but fails when you have already typed a prefix (or
suffix) of the directory.

The problem with _generic is that _main_complete has special handling for
tildes and equals. _history already works around this: you need to move
the ~ back to $PREFIX from $IPREFIX.

I've attached a fixed function that also has a replacement for the pidof
that will work on Solaris. I think lsof can also be used on other
platforms. Would be nice to support the BSDs. It may also be possible to
better filter the processes: just those with a controlling tty perhaps?

readlink is replaced by zsh's internal :A modifier and the current
process is filtered out. It also enables partial completion for /
and pattern matching so if you know that another shell is in a src
directory, you can type *src and the widget will complete that to the
right directory.

>   zstyle ':completion:term_list:*' completer _term_list

I'd recommend changing that to the more specific
  zstyle ':completion:term_list::::' completer _term_list

In at least my setup a different completer style would otherwise take
precedence.

> Btw, I'm not sure if "advertisement" is allowed here. I have submitted
> the plugin to the oh-my-zsh project. But without any testers, they don't
> want to merge it in to the mainline project. So if anybody is interested
> you can test it... =)

I'd have thought the function itself was something we could include in
the main zsh distribution if people are agreeable? I'm not too sure on
the name but am struggling to offer something better - foreign-pwds,
external-pwds perhaps?

For omz, you might want to consider a different keystroke. Ctrl-V has
an existing purpose that some people might not be pleased to have
replaced.

Oliver

#autoload

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)"}:#$$:*}%%/*} ) ;;
  linux*) dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:A) ) ;;
esac
dirs=( ${(D)dirs} )

compstate[pattern_match]='*'
_wanted directories expl 'current directory from other shell' \
    compadd -M "r:|/=* r:|=*" -f -a dirs



Messages sorted by: Reverse Date, Date, Thread, Author