How to change default shell for Linux susbsystem for Windows
Since Fall Creators Update you can use chsh
to setting default shell. This still doesn't work if you are running WSL using bash.exe
command but this work if you running WSL with ubuntu.exe
command.
Also, since Fall Creators Update we should to install WSL OS from Windows Store.
Set zsh
as default shell:
chsh -s /bin/zsh
then run (or restart) ubuntu.exe
from command prompt.
You cannot change the default shell per se since the Linux subsystem is started via the bash.exe residing in the system directory.
You can, however, make a new shortcut like the one that already exists for bash and make it run the command
%systemroot%\system32\bash -c /usr/bin/fish
This way you will be running fish immediately.
Open bash, run nano ~/.bashrc
and paste this in:
if [[ -t 1 && -x /usr/bin/zsh ]]; then
exec /usr/bin/zsh
fi
Just change the shell to fish
or whatever you want. The -x
check is important if you ever re-install Bash -- you won't be able to open it after a fresh install because the exec
command will fail and then Bash just closes.
If that happens, delete/rename your .bashrc
file here:
C:\Users\<USERNAME>\AppData\Local\lxss\home\<USERNAME>\.bashrc
The -t
I believe checks if stdout is open. Not sure why that's important, I copied it from this article.