4 ms·
Why not just set a shebang like $ cat foo.sh #!/usr/bin/env zsh echo $SHELL Which most editors understand. $ file foo.sh foo.sh: a /usr/b
by ebeip90 7y ago
Why not just set a shebang like
$ cat foo.sh
#!/usr/bin/env zsh
echo $SHELL
Which most editors understand.
$ file foo.sh
foo.sh: a /usr/bin/env zsh script text executable, ASCII text
$ vim --clean -c ':set filetype?' foo.sh
...
filetype=zsh
This ALSO ensures that the correct shell is invoked on your script, instead of your current or default shell.
$ ./foo.sh
/usr/local/bin/zsh
- k_sze 7y agoIf the script file is meant to be sourced only, then a shebang is bad style as it gives the wrong hints to human readers.
- JetSpiegel 7y agochmod -x
- dmix 7y agoI don't see how that helps either of my examples (TODO.md, config files). Even when it's actual part of ZSH script I'm only using `ft=zsh` when it's a file I'm sourcing, not intended as a runnable script by itself. For example: `~/.exports` which includes my PATH and env variables, as I also import it into `.bashrc` in addition to `.zshrc`.