Frage

I recently switched from bash to zsh. How can I achieve the following tab completion behavior:

Enter the first letters, then press TAB. Complete the entry until the first ambiguous letter and immediately show the options / alternatives.

Currently, it behaves like this:

# ls .m*
  .mysql_history  .matlab  .matplotlib  .mono  .mozilla
# cd .m<TAB>
  .matlab/  .matplotlib/  .mono/  .mozilla/
# cd .mo<TAB>
  .mono/  .mozilla/
# cd .ma<TAB><TAB> (here two tabs are necessary: the first one completes to .mat, 
                    the second one show .matlab and .matplotlib)

I'd like to get rid of the second tab in the last case. Is this possible with zshs completion system?

Here is my current .zshrc:

HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=1000

# Options
setopt autocd

# Aliases
alias ls='ls --color -h --group-directories-first'
alias ll='ls -laF --color -h --group-directories-first'
alias la='ls -A --color -h --group-directories-first'


alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# Prompt
PS1="[%n@%m]%F{112}[%~]%f# "

# Enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi

# Set vim mode
bindkey -v

# Key bindings
# Vi insert mode
bindkey -M viins 'jj' vi-cmd-mode
bindkey -M vicmd '^i' vi-down-line-or-history
bindkey -M vicmd '^k' vi-up-line-or-history

# Vi command mode
bindkey -M vicmd 'l' vi-forward-char
bindkey -M vicmd '^l' vi-forward-word
bindkey -M vicmd 'j' vi-backward-char
bindkey -M vicmd '^j' vi-backward-word
bindkey -M vicmd 'h' vi-insert
bindkey -M vicmd 'i' vi-down-line-or-history
bindkey -M vicmd 'k' vi-up-line-or-history

# Environment variables
export TERM=xterm-256color

# Completion
zstyle :compinstall filename '/home/jeschma/.zshrc'

autoload -Uz compinit
compinit
War es hilfreich?

Lösung

Ok, i've found out that the zsh option listambiguous was set by default. I just inserted unsetopt listambiguous into my zshrc and my problem was solved. Now the possible completions are show with a single TAB press every time.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top