zshell 是制表符补全不明确的选项

zshell 是制表符补全不明确的选项

我一直遇到 zsh 完成的问题,这已经成为一个相当大的烦恼。它正在完善那些不明确的地方的选项。例如,在包含以下文件的目录中:

tilertest1x1-00_1408311424.logtilertest1x1-00_1408311424.roottilertest2x2-00_1408311501.logtilertest2x2-00_1408311501.roottilertest3x3-00_1408311527.logtilertest3x3-00_140 8311527.root
​ ​ ​ ​



如果我输入“less ti”,然后点击 Tab,zsh 将完成此“tilertest-00_1408311”。而不是停止在我想要的地方(“tilertest”)。奇怪的是,如果我提供任何类型的路径(即“less ./ti”),它似乎工作得很好。我怎样才能改变它以在第一个歧义处停止?我已经包含了我的 .zshrc 文件。我还应该注意我正在使用 oh-my-zsh。

# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="cmilke01"

# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Uncomment the following line to use case-sensitive completion.
 CASE_SENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

 # Uncomment the following line to disable colors in ls.
 # DISABLE_LS_COLORS="true"

 # Uncomment the following line to disable auto-setting terminal title.
 # DISABLE_AUTO_TITLE="true"

 # Uncomment the following line to disable command auto-correction.
  DISABLE_CORRECTION="true"

 # Uncomment the following line to display red dots whilst waiting for     completion.
 # COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-  zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git)

source $ZSH/oh-my-zsh.sh

# User configuration

export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl"
# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"

答案1

控制此行为的一部分的选项是menu_complete。所以,你需要:

unsetopt menu_complete

(但 oh-my-zsh 似乎已经做到了这一点)。如果这还不够,万一 oh-my-zsh 做了什么特别的事情,你也可以尝试:

zstyle ':completion:*' completer _complete
bindkey '\t' expand-or-complete

您还可以将行为与zsh -f新 shell 进行比较:

autoload -U compinit
compinit
bindkey -e

如果您在这里得到不正确的行为,这可能是您的 zsh 版本中的错误。否则,尝试查看哪个 oh-my-zsh 更改(在其文件中)触发了问题。在按下该Tab键之前,您可以输入CtrlX h 以获取有关以下完成的上下文信息(这可能会帮助您找到发生了什么)。

一旦找到解决方案,为了使其永久有效,请将其放入您的.zshrc oh-my-zsh 所做的任何更改,通常位于文件末尾或附近。

相关内容