Using VS Code remote SSH with fish as login shell
VS Code remote SSH would not
connect to a machine where my login shell was fish. It installs and starts
its server side by running a POSIX shell script over the SSH connection, and
fish does not run those.
The fix is to keep a POSIX shell as the login shell and hand over to fish only for interactive sessions. Change the login shell back:
$ chsh -s /bin/bash
then, in ~/.bashrc:
if [[ $- == *i* ]] && [[ -z "$BASH_EXECUTION_STRING" ]] && command -v fish >/dev/null; then
exec /home/mycroft/.nix-profile/bin/fish
fi
Both tests matter:
$-containsionly in an interactive shell, so a plainbash script.shorbash -cnever reaches theexec.BASH_EXECUTION_STRINGis set whenever bash was given a command string,bash -icincluded – an interactive shell that is still only there to run one command. That is the case the first test alone would miss.
So logging in for a prompt still lands in fish, while anything running a command over SSH stays in bash.