zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Mailinglist <zsh-users@sunsite.dk>
Subject: Re: TAB at the command line beginning
Date: Wed, 21 Jul 2004 17:32:36 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0407211649070.20062@toltec.zanshin.com> (raw)
In-Reply-To: <20040721224712.GJ7828@ay.vinc17.org>

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" ]].


  reply	other threads:[~2004-07-22  0:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-21 19:53 Igor Ahmetov
2004-07-21 22:47 ` Vincent Lefevre
2004-07-22  0:32   ` Bart Schaefer [this message]
2004-07-25 18:40     ` zzapper
2004-07-26  0:23       ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0407211649070.20062@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).