From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5339 invoked from network); 22 Jul 2004 00:35:27 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Jul 2004 00:35:27 -0000 Received: (qmail 65651 invoked from network); 22 Jul 2004 00:35:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Jul 2004 00:35:21 -0000 Received: (qmail 26373 invoked by alias); 22 Jul 2004 00:34:39 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7732 Received: (qmail 26363 invoked from network); 22 Jul 2004 00:34:39 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 22 Jul 2004 00:34:39 -0000 Received: (qmail 63222 invoked from network); 22 Jul 2004 00:32:41 -0000 Received: from unknown (HELO moonbase.zanshin.com) (167.160.213.139) by a.mx.sunsite.dk with SMTP; 22 Jul 2004 00:32:38 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i6M0WaQh026207 for ; Wed, 21 Jul 2004 17:32:36 -0700 Date: Wed, 21 Jul 2004 17:32:36 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: Zsh Mailinglist Subject: Re: TAB at the command line beginning In-Reply-To: <20040721224712.GJ7828@ay.vinc17.org> Message-ID: References: <20040721195315.GA2732@home> <20040721224712.GJ7828@ay.vinc17.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Thu, 22 Jul 2004, Igor Ahmetov wrote: > Is it possible to imitate tcsh's behavior with 'set autolist', which, > when TAB pressed just at the beginning of the command line, prints list > of files and directories in the current dir (zsh by default just inserts > plain TAB, which in my opinion is rather useless). Zsh offers two options when completing at the beginning of the line: Insert a tab, or complete. This normally completes command names, not local files, because generally the start of line is where you type a command, but it might complete something else in some contexts. For example, when I type TAB at the beginning of the command line, I get: schaefer[501] zsh: do you wish to see all 4238 possibilities (3677 lines)? To get completion at start of line, you have to be using compsys (run "compinit" from your startup files), and you must have set the insert-tab zstyle properly. I have it set to "pending" (explained in the docs) so I get completion when I'm typing but plain TABs when I'm cut'n'pasting. If you want to complete something other than command names, you need to write a little function and install it as the completion function for the -command- context, like so: _command_position() { if [[ -z "$BUFFER" ]] then _files else _autocd fi } compdef _command_position -command- (Note _autocd is the name of the default -command- function.) On Thu, 22 Jul 2004, Vincent Lefevre wrote: > It would be much better if this would be configurable. For instance, > I'd prefer a history-incremental-search-backward. The way to configure _that_ is to create your own binding for TAB. history-search-or-complete-word() { if [[ -z "$BUFFER" ]] then zle history-incremental-search-backward "$@" else zle complete-word "$@" fi } zle -N history-search-or-complete-word bindkey '\t' history-search-or-complete-word You can do more complicated tests than [[ -z "$BUFFER" ]] ... one that might be interesting is [[ -z "$BUFFER" && -z "$PREBUFFER" ]].