How to change the default shell in Cygwin?
Solution 1:
The answer depends on how you start Cygwin.
If you start Cygwin with Cygwin.bat, modify the last line of /Cygwin.bat
(usually C:\cygwin\
or C:\cygwin64\
).
If you start Cygwin with mintty, then add the shell as a parameter: mintty /usr/bin/zsh -
Solution 2:
If you run mintty.exe
directly or run Cygwin Terminal from the start menu or desktop (which is a shortcut to mintty.exe), you can set the SHELL environment variable in Windows to /usr/bin/zsh
.
On Windows 7:
- Press Windows key.
- Start typing "environment".
- When it appears, select "Edit environment variables for your account".
The rest should be self-explanatory.
Solution 3:
Copied from my answer on Stack Overflow:
Instead of creating a passwd file, which Cygwin recommends against1, you could edit /etc/nsswitch.conf. Add or edit the following line:
db_shell: /usr/bin/fish
The down/up side of this method is that, if you have multiple users, this change affects all of them. The up/up side is that it's dead simple. The only catch is that you have to restart Cygwin.
If you do use mkpasswd after this change, it will use your new default shell for all users that are allowed to log on.
1 The mkpasswd documentation says this:
Don't use this command to generate a local /etc/passwd file, unless you really need one. See the Cygwin User's Guide for more information.
I can't really find any solid reasoning in the user's guide, other than a mention that you'll have to regenerate the /etc/passwd and /etc/group files if your users and groups change, which I suppose is a decent enough reason. I can say that the process is somewhat error prone for newbies.
Solution 4:
This is a hack: put this as the first line of your ~/.bash_profile
:
exec zsh