This question was previously asked here: https://stackoverflow.com/questions/74808784/after-switching-default-shell-command-file-just-opens-terminal
However, I have found no reason for the behavior, so I'm re-asking it here so that maybe someone more knowledgeable about fish can figure out a more satisfying answer.
Here's the problem: .command files have long been used on macOS to be able to quickly double-click and execute a script in the Terminal. Normally, when you double-click a .command file, it opens a new Terminal window and then immediately executes the script.
The Terminal also has a preference to set a default shell. For example, I've downloaded the self-contained fish app and then set this Terminal preference [Terminal menu --> Preferences --> General --> Shells open with: --> Command (complete path):] to the following: /Applications/fish.app/Contents/Resources/base/usr/local/bin/fish
Now, however, when I double-click on .command files, the Terminal simply opens with a new fish shell and does nothing. Why? Is there a way to fix this?
Here's the entirety of a sample .command file that works fine when the Terminal's preference is set to the default shell of zsh. Note that yes, execute permissions have been set on this file:
#!/bin/zsh
/Applications/Chrome.app/Contents/MacOS/Google\ Chrome --guest
do shell script ...?