Open zsh scripts in sh-mode in emacs

Viewed 3662

*.zsh files open in the default mode (text-mode for me). However, sh-mode is actually multiple modes including behaviours for zsh, bash, etc. How can I tell emacs to open *.zsh files specifically in the zsh flavor of sh-mode?

3 Answers

If you use the shebang method, a more robust form is

#!/usr/bin/env zsh
# env will search the path for zsh.  Some distros may put it a different place.
# env is pretty much guaranteed to be in /usr/bin
Related