I have tried to configure ZSH to be the default shell that is used for the integrated terminal. However, bash is opened every time even though ZSH is set as the default profile when connecting to a remote workspace (on a linux machine).
Here is my local settings config (/Users/ewiener/Library/Application Support/Code/User/settings.json
):
"terminal.integrated.profiles.linux": {
"zsh (login)": {
"path": "zsh",
"args": [
"-l"
]
},
"zsh": {
"path": "/usr/local/bin/zsh",
},
},
"terminal.integrated.defaultProfile.linux": "zsh (login)",
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "MesloLGS NF",
My remote server has no terminal settings set in /home/ewiener/.vscode-server/data/Machine/settings.json
.
The workspace settings also has no terminal settings (/home/ewiener/myrepo/.vscode/settings.json
)
What can I do to ensure ZSH is opened when connecting to a remote workspace? Even if I manually select ZSH as the shell, it will revert to bash if I close and re-open the workspace.
My original answer didn't always work for me, so I instead decided to have my .bashrc
change the shell to zsh whenever VSCode opened up a shell. You can do this by adding the following to the top of your .bashrc
:
if [[ "$TERM_PROGRAM" == "vscode" ]]; then
# ~/.profile is run by the login shell (this is what ssh uses)
# ~/.bashrc is run by the interactive shell (this is what vscode uses)
# Therefore, we only need to change the shell to zsh here since
# vscode will run ~/.bashrc for us.
exec zsh -l
fi
I realized that the correct terminal was opening locally and the issue only happened on the remote workspace. This led me to modify my SSH config which ended up providing the solution.
You can modify your SSH configuration and set the terminal you want to use for your specific host.
Remote-SSH: Open SSH Configuration File..
SetEnv TERM=<terminal>
Ex:
# /Users/username/.ssh/config
Host linux-server
HostName 00.00.00.00
User username
SetEnv TERM=/usr/local/bin/zsh # <---- this will update your terminal
Make sure you are editing your .ssh/config
on your local computer (not on the remote server).
Edit
Please note the SetEnv directive is supported since OpenSSH 7.8 (check with sshd -V
). Source