9

I've installed Linux subsystem for Windows 10. It works fine, but I want to change the default shell environment for the subsystem.

I did sudo apt-get install fish and then chsh -s /usr/bin/fish. But when I start bash.exe in Windows, it always starts the bash (I think it is predictable).

Does anyone know arguments to change this behavior?

  • When you start bash.exe you are obviously explicitly starting bash. I'm not familiar with the Linux subsystem in Windows 10, but I would expect there to be some way to start a "Linux" shell without explicitly starting one specific shell. – a CVn Aug 7 '16 at 19:25
  • Did you tried an ugly edition of your bashrc or bashprofile to re-route interactive bash calls to fish? Adding a line like isatty && exec fish may worth the try when you are totally out of actual solutions. – A. Loiseau Aug 7 '16 at 22:52
5

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.

  • 1
    I used %systemroot%\system32\bash.exe ~ -c /bin/zsh to make ZSH open in my home directory. – David Pärsson Aug 11 '16 at 20:13
  • Alternatively, set the "Start in" field in the shortcut to %userprofile% to start the shell in your home directory. – dOxxx Sep 29 '16 at 2:07
  • @konqui This doesn’t break any other shell. It’s a new shortcut for starting it. Your bash will work just fine – Sami Kuhmonen Nov 1 '17 at 7:49
  • @SamiKuhmonen there wasn‘t anything said about a new shortcuts - i corrected it now i can life with this answer. – konqui Nov 1 '17 at 7:54
8

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.

4

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.