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.
-
Don't know about zsh but for bash, there is a bash-completion package that allows this type of completion and powerful ones like completion over ssh for scp for example.
Seems this link will help you.
-
This may or may not be a useful answer - switch to bash, which does what you want out of the box.
f3lix : That's somewhat like telling an vim user to switch to emacs, because he can't find a configuration switch... IMHO zsh is more powerful than bash and also comes with a great completion function. You just have to activate it... -
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
x-way : Thank you, this configures exactly the behavior I was looking for.Masi : What does the option z does in your code?f3lix : autload commandline options: -U -- suppress alias expansion for functions -k -- mark function for ksh-style autoloading -t -- turn on execution tracing for functions -w -- specify that arguments refer to files compiled with zcompile -z -- mark function for zsh-style autoloading -
In fact I now discovered that the problem does not seem to come from the configuration. When using a
.zshrcwhich only containsautoload -Uz compinit compinitThe 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 .. -
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 trueto my config and now everything works fine again.
0 comments:
Post a Comment