views:

25

answers:

1

I have a bash-tab-completion script for Apache's Hadoop. Normally, I use zsh as my day-to-day shell. It tends to be pretty bash-like when I need it to be, but it looks like the tab-completion systems are radically different between them. Is there a simple way to "convert" the existing bash-tab-completion definitions to work in zsh? I don't want to invest a ton of time in this, but if it's easy I'd save a moderate amount of effort.

+3  A: 

From this page (dated 2010/01/05):

Zsh can handle bash completions functions. The latest development version of zsh has a function bashcompinit, that when run will allow zsh to read bash completion specifications and functions. This is documented in the zshcompsys man page. To use it all you need to do is run bashcompinit at any time after compinit. It will define complete and compgen functions corresponding to the bash builtins.

Dennis Williamson
The good news: I think this should work, so thanks a lot. The bad news: for some reason, the system I'm trying to accomplish this on doesn't seem to load /etc/zshrc when I log in via SSH. I don't know enough about the login process to tell why this is the case. Maybe time to ask another question...
Coderer
@Coderer: First of all, you say "/etc/zshrc". On my system, it's `/etc/zsh/zshrc`. Also, check the following files in reverse order (listed in the order they are sourced during zsh startup): `/etc/zsh/zshenv`, `$ZDOTDIR/.zshenv`, `/etc/zsh/zprofile` and `$ZDOTDIR/.zprofile` (probably `~/.zprofile`) to see if the `RCS` variable is unset. If it is, that would prevent the subsequent files after the file in which it's unset from being sourced. Finally, check the shell for the user in `/etc/passwd` and make sure it's `zsh` and make sure it doesn't have a `-f` argument.
Dennis Williamson
Thanks for all the feedback -- I resorted to the #1 classic programmer hack, "stdout debugging" (echo statements in each startup script) and found the issue. For some reason, our /etc/zprofile was sourcing the various /etc/profile.d scripts, which were then getting sourced *again* in /etc/zshrc. Simply moving the autoload statements to the top of /etc/zprofile fixed the problem.
Coderer