From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10217 invoked by alias); 11 Nov 2014 10:17:42 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19366 Received: (qmail 26926 invoked from network); 11 Nov 2014 10:17:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; bh=i0O0urxfg9GTNj/rbMJiT/j7okEbg/hYyl7xkVKt9mM=; b=IyL4ld/En0FS22HiA2wmBI4AFOhuomCmDMep/s/m55KZkGIKPtTwaaGLsUasdcZ8El sA8kOoRgLlNyNw6Wr8ZzkGM0uX9fT0Pu6Nli4c4DRsnM9HHL3jU8abgCbVibkFbP8JcB aXEsbwaEK2NvImZ43hjo45sF+rrxt4KAz9T6B3ElNJmiz9TZyIzvWf2eQXmo0kRCN1yo urt4arBo4jkV/gC+mPjriaN6OPdkDl5REPucgSHkwHZGuD9DNrOQQYPCZMsI+Y20M/nW RrUKYUYEpEXE3n+g1Ylr9vFQJU3joJhcvaz3k9tDCORF/mIHkif/Gt5EEdu0Xv+Xc5+8 djJw== X-Received: by 10.194.62.226 with SMTP id b2mr50988280wjs.46.1415701058376; Tue, 11 Nov 2014 02:17:38 -0800 (PST) Message-ID: <1415701057.1247.1.camel@gmail.com> Subject: Re: How to add a 'non-escaped' tilde to the completion list From: Death Jester To: Oliver Kiddle Cc: zsh-users@zsh.org Date: Tue, 11 Nov 2014 11:17:37 +0100 In-Reply-To: <17517.1415653425@thecus.kiddle.eu> References: <1415617649.1260.4.camel@gmail.com> <20141110113136.34766361@pwslap01u.europe.root.pri> <20141110121802.6f9434c4@pwslap01u.europe.root.pri> <1415625666.1260.8.camel@gmail.com> <15435.1415627852@thecus.kiddle.eu> <1415633542.1260.10.camel@gmail.com> <17517.1415653425@thecus.kiddle.eu> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.7-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit On Mon, 2014-11-10 at 22:03 +0100, Oliver Kiddle wrote: > 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? That would be awesome! I think a short name for 'external-pwds', like 'ext_pwds' sounds good to me... > > 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. Yes, of course. Unfortunately I don't have an overview what keys are already bound to something. Ctrl+V seemed to be available. But I'm open for other suggestions. > > 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 I tested your new function on Linux (with version string: 'zsh 5.0.7 (x86_64-pc-linux-gnu)') and it works for me. I have also tested the cases 1) The list is empty except the current shell (works -> no list only '~' on commandline) 2) I start to type and then hit the completion button (works -> sublist appears) I have replaced the zstyle line as you suggested: zle -C term_list menu-complete _generic bindkey "^v" term_list zstyle ':completion:term_list::::' completer _term_list I neither have a BSD, nor a Solaris machine, so I can't test it for Solaris, or implement it for BSD... Thank you for your awesome help Peter and Oliver. Cheers, Julian