Zsh tab-completion for “cd ..” [closed]

牧云@^-^@ 提交于 2020-06-24 04:59:04

问题


How can I configure the Zsh tab-completion such that when I type cd ..<TAB> it expands to cd ../ and after pressing <TAB> again proposes the folders in the parent directory for completion?

E.g. it should show the same behavior as when typing for example cd Documents<TAB> which expands to cd Documents/ and after pressing <TAB> again proposes the folders in Documents for completion.

As a starting point for configuration I use an empty .zshrc and Zsh 4.3.9 from MacPorts.


回答1:


Same problem with debian unstable, Ubuntu jaunty, both ship zsh 4.3.9. I know of multiple people with different configurations.

After reading http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514152 I added

zstyle ':completion:*' special-dirs true

to my config and now everything works fine again.




回答2:


Put this into your ~/.zshrc:

autoload -Uz compinit
compinit

There is also a project with zsh functions/configurations for Mac OS X on http://code.google.com/p/zsh-templates-osx/ . Personally I think it's an overkill to use the whole package. But found it useful to cherry pick some tricks, functions, completions etc. and create my own .zshrc




回答3:


In fact I now discovered that the problem does not seem to come from the configuration. When using a .zshrc which only contains

autoload -Uz compinit
compinit

The tab-completion works as intended for cd ..<TAB> when using the default Mac OS X Zsh (4.3.4). But with the MacPorts Zsh (4.3.9) the tab-completion only works for other folders and not for ..




回答4:


This may or may not be a useful answer - switch to bash, which does what you want out of the box.



来源:https://stackoverflow.com/questions/564648/zsh-tab-completion-for-cd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!