Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Default Shell in Cygwin

Tags:

shell

cygwin

fish

I've been using Cygwin for quite a while now. I now want to switch to fish from bash. Everyone is saying that you should use chsh -s /usr/bin/fish, but for some reason, chsh does not work for me. Trying to modify my Cygwin.bat file doesn't work either, and neither does changing my /etc/passwd file.

I really don't understand what's going on. Could someone please help me?

like image 828
Alex Avatar asked Mar 12 '14 20:03

Alex


People also ask

What shell does Cygwin use?

The Cygwin installation creates a Bash shell along with a UNIX environment by which you can compile and run UNIX-like programs. Using this one can even create an emulated X server on your windows box and run UNIX-like GUI software tools.


1 Answers

Try editing /etc/nsswitch.conf instead of /etc/passwd

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.


References

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.

like image 129
P Daddy Avatar answered Sep 16 '22 23:09

P Daddy