我对自己的智慧有点研究......我只需要问。
我在小牛机器上有哦-my-zsh并且更新了所有内容。我也有Xcode和Brew。全部更新。根据这个页面:https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet我不应该只是打字,说:" g" [tab]并获得" git"?或键入" md" [tab]并获得" mkdir -p"?现在我只是得到一个我可以通过选项卡(或箭头)的选项列表......我认为它会自动完成。我错过了什么?
我觉得这可能与我的$ PATH有关,但这也是我感到困惑的地方......应该指向哪里?
我非常欣赏和启发。
# Path to your oh-my-zsh configuration.
#ZSH=$HOME/.oh-my-zsh
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="af-magic"
ZSH_THEME="agnoster"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git textmate sublime zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
#export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/$
#export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=/usr/local/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
zstyle ':completion:*' list-prompt ''
zstyle ':completion:*' select-prompt ''
autoload -Uz compinit
compinit
答案 0 :(得分:1)
别名基本上只是命令的短名称。在执行命令之前,zsh在内部用其值替换别名。但默认情况下,使用完成时不会扩展别名( Tab ),它们的处理方式与其他任何命令一样。
例如:
alias ll='ls -l'
alias la='ls -al'
如果您现在键入l
Tab ,zsh会显示以l
开头的每个命令,包括别名ll
和la
。如果您键入ll
Tab ,它可能只会在ll
之后添加一个空格(假设没有其他命令以ll
开头)。
当您运行ll somedir
时,它与ls -l somedir
完全相同。您甚至可以添加ls
的其他选项:ll -t somedir
运行ls -l -t somedir
。
话虽如此,如果您想在键入 Tab 时扩展别名,zsh
可以这样做。
有两种方法:
您可以调用_expand_alias
小部件。在 emacs模式(bindkey -e)中,它绑定到^Xa
(按 Control + X 然后 A )。
您可以将_expand_alias
添加到completer
样式。似乎 oh-my-zsh 不会将此样式更改为其默认值,因此添加
zstyle ':completion:*' completer _expand_alias _complete _ignored
到~/.zshrc
应该有效。
(要保存,您可以使用zstyle -L ':completion:*' completer
打印当前设置,_expand_alias
必须在_complete
之前
如果您现在输入ll
标签,zsh
会立即将其替换为ls -l
。
注意:在这两种情况下,光标必须位于替换发生的别名之后或之后。这也意味着如果自动完成,您必须键入整个别名或退格(_completer
成功完成后添加空格)