zsh完成完全明确的词干,显示多个匹配

时间:2013-01-11 17:56:15

标签: zsh zsh-completion

假设在命令行输入:

cd wi<TAB>

我有两个目录

windows/   wind-tunnel/

我没有回应。我希望

  1. 完成“风”
  2. 打印2个建议的完成
  3. 我不知道为什么shell不会使这些中的任何一个成为默认行为。使用zsh丰富的完成系统,我无法搜索满足这些功能的行为。我曾经用tcsh的'增强'来获得这种行为,但是我不记得的因素让我确信zsh是前进的方向。

    请有人指出我正确的方向。

    提前感谢任何回复的人(虽然我会在结束问题之前亲自表示感谢)。这是我的zsh配置(我不完全理解,但大多数行是有原因的):

    setopt bash_auto_list; 
    setopt no_auto_menu; 
    unsetopt ALWAYS_LAST_PROMPT; 
    
    # ^ = control
    # \e or ^[ = meta / option / alt
    
    # _approximate - gives that beloved CSH complete=enhance in zsh
    # _complete - ensures we don't put a slash on the end of dirs when there are other longer matches
    # (otherwise we'd have to delete the slash and type the first letter of a longer completion)
    # http://grml.org/zsh/zsh-lovers.html
    #zstyle ':completion:*' completer _complete _approximate  
    
    autoload -U compinit promptinit
    compinit -C
    promptinit
    
    ## case-insensitive (all),partial-word and then substring completion
    #zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
    
    # (Actually, I have more items in my matcher list, but I don't know how complicated you want your 
    # matcher list to be.) Basically that means to prefer simple completion most, case insensitive 
    # completion next, and finally to try replacing '-' with '_' and vice versa if no completion has 
    # been found with the first two methods. If you'd like to know what else I have in my matcher list, 
    # let me know.
    zstyle ':completion:*:complete:*' matcher-list '' '+m:{a-zA-Z}={A-Za-z}' '+m:{-_}={_-}'
    
    # tab completion for PID :D
    zstyle ':completion:*:*:kill:*' menu yes select
    zstyle ':completion:*:kill:*' force-list always
    
    ##################################
    
    fpath=($fpath /usr/local/share/doc/task/scripts/zsh ~/.zsh-completion-functions)
    autoload -Uz compinit
    compinit
    
    # be verbose, i.e. show descriptions
    zstyle ':completion:*' verbose yes
    zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
    
    # group by tag names
    zstyle ':completion:*' group-name ''
    
    ##############################
    ## Maven
    ##############################
    
    #function listMavenCompletions { reply=(cli:execute cli:execute-phase archetype:generate compile clean install test test-compile deploy package cobertura:cobertura jetty:run -Dmaven.test.skip=true -DarchetypeCatalog=http://tapestry.formos.com/maven-snapshot-repository -Dtest= `if [ -d ./src ] ; then find ./src -type f | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi`); }
    #compctl -K listMavenCompletions mvn
    
    #source ~/.zsh-tab-completions-mvn
    # COMPLETION SETTINGS
    # add custom completion scripts
    #fpath=(~/.zsh/completion $fpath)
    autoload -U compinit
    compinit
    zstyle ':completion:*' menu select=2
    

1 个答案:

答案 0 :(得分:0)

我似乎无法重现这一点。使用~/.zshrc,我会收到以下行为:

charmander% ls
wind-tunnel windows
charmander% cd w<TAB>   # Completes to `wind`:
charmander% cd wind<TAB><TAB>   # Requires two tabs to bring up menu, not sure why. 
local directory
wind-tunnel/  windows/
charmander% cd wind

有趣的是,当我不提取任何启动文件时,我会收到此行为:

charmander% zsh -f
charmander% cd w<TAB>   # Completes to `wind`:
charmander% cd wind<TAB>
wind-tunnel/  windows/

除非其他人设法使用您的~/.zshrc重现此问题,否则在问题中添加更多信息会有所帮助,尤其是zsh启动文件中的任何信息:

  • /etc/zshenv
  • /etc/zprofile
  • /etc/zshrc
  • /etc/zlogin
  • ~/.zprofile
  • ~/.zshrc
  • ~/.zlogin