I have searched around but could not find anything conclusive. Is there a difference between the alias command in zsh and the alias command in bash? If not, does it mean I can share a set of aliases between the two shells and expect them to work as I intended?
According to the Zsh Workshop Aliases they seem to have the same syntax, so they should work.
The syntax of the
The same holds for variable definitions and function definitions, as long as you use the subset of syntax that's supported in all shells.
If you don't use versions of zsh older than 4.0, you can put all your shell-agnostic definitions in a file called (say)
This tells zsh to expect sh compatible syntax in this file only. Then source that file near the beginning of
This is basically what I do. For example, I have somewhat complex code that generates an alias for