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

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



On 11/11/14 10:03, Oliver Kiddle wrote:
> #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

I would suggest this addition to the function:

dirs=( ${dirs//\/proc\/*\/cwd/} )

This removes unexpanded directories from the list. This can happen when
a shell's directory has been removed, which pretty regularly is the case
for me with auto-generated build directories.

-Jan



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