Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Force file completion when hitting TAB twice
- X-seq: zsh-users 14660
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Force file completion when hitting TAB twice
- Date: Fri, 18 Dec 2009 10:46:16 +0000
- In-reply-to: <20091217175808.2e860888@xxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: CSR
- References: <20091217175808.2e860888@xxxxxxxxxxxxxxxxxxx>
On Thu, 17 Dec 2009 17:58:08 +0100
"Yuri D'Elia" <wavexx@xxxxxxxxxxxx> wrote:
> Hi everyone. I'm trying to customize the completion of zsh so that:
>
> * when I hit TAB the default _complete completer is used.
> * if no completions are available, I get a beep.
> * if I hit TAB again, or hit TAB twice, I get a _files completer
> (offering me to complete filenames regardless of the context).
Try this and let us know how you get on... $LASTWIDGET test is
unsophisticated but probably covers the most obvious cases.
_complete_failed() {
# Only complete if first attempt at completion failed.
# Usage:
# zstyle ':completion:*' completer _complete _complete-failed
# zstyle ':completion:complete-failed:*' completer <your-completers>
if [[ $LASTWIDGET = *complete* && -z $_complete_failed_active ]]; then
local _complete_failed_active=1
local -a completers
local curcontext="complete-failed:::"
_main_complete "${completers[@]}"
fi
}
zstyle ':completion:*' completer _complete _complete-failed
zstyle ':completion:complete-failed:*' completer _files
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author