2013-02-28 81 views
3

我最近從bash切換到zsh。如何實現以下標籤填寫行爲:zsh:強制單選項卡完成

輸入第一個字母,然後按TAB。完成入口直到第一個含糊不清的字母,並立即顯示選項/備選方案。

目前,它的行爲是這樣的:

# 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) 

我想在最後一種情況下襬脫了第二個選項卡中。這可能與zshs完成系統?

這是我目前的.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="[%[email protected]%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 

回答

4

好吧,我發現,zsh的選項listambiguous被默認設置。我只是在我的zshrc中插入了unsetopt listambiguous,我的問題解決了。現在可能的完成將每次顯示一個單獨的TAB按鈕。