====== Switching from bash ======
The Linux Magazine ran a couple simple articles explaining how the Bash user can
change to Zsh. Here is the link for the one about switching
[[http://www.linux-mag.com/2002-05/power_01.html|http://www.linux-mag.com/2002-05/power_01.html]].
Also the zsh distribution comes with a script bash2zshprompt that converts bash
prompts to zsh. This script is not installed, it is only available in the zsh source
distribution under Misc/ (also at: [[http://zsh.cvs.sourceforge.net/*checkout*/zsh/zsh/Misc/bash2zshprompt|bash2zshprompt]])
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.
bash completions are typically stored in files which must be sourced (bash doesn't
have autoloadable functions) I use the following function to source these files:
bash_source() {
alias shopt=':'
alias _expand=_bash_expand
alias _complete=_bash_comp
emulate -L sh
setopt kshglob noshglob braceexpand
source "$@"
}
This uses aliases to avoid the bash shopt builtin and to avoid problems with common
bash functions that have the same name as zsh ones. It also sets zsh options to best
emulate bash.
It is probably better to use function autoloading however.
The have() function commonly used with bash completions doesn't work in zsh 4.0. The
following is a replacement which you can use instead.
have() {
unset have
(( ${+commands[$1]} )) && have=yes
}
Keep in mind that it is much better to rewrite completion functions for zsh than to
spend much time getting a bash function to work with this.
For cygwin users: Cygwin by default creates a shortcut to bash, you can create a
shortcut for zsh by using the mkzsh command that comes with the cygwin version of
zsh. Run "mkzsh -h" to get usage information.