Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I configure zsh to be the default shell under Cygwin?

share|improve this question

migrated from stackoverflow.com Oct 28 '11 at 2:58

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 39 down vote accepted

Unless you're using cygwin as a multiuser environment (in which case use chsh as you would under a standard environment.)

Otherwise, you just change cygwin.bat to run zsh -l -i instead of bash --login -i and it will run as a login shell.  

Of course, if you want to run multiple shells from startup, just create a set of .bat files to load different shells. (sh, ksh, csh, fish etc)

Update...

I felt I should update this to provide info on doing this without chsh but still doing it on the Unix end. Edit the /etc/passwd file and replace occurrences of /bin/bash with /bin/zsh. (This is effectively what chsh would do, but this way you'd do it for all users in one go.)

share|improve this answer
1  
There is no longer an /etc/passwd in cygwin by default, and chsh is no longer supported. This answer does not help (April 10, 2014). –  Jeff Snider Apr 10 at 14:51

If I read your question right, you're looking for something else than what chere supplies (which, granted, is pretty cool in its own right).

The current version of Cygwin doesn't have an /etc/passwd file, and the system I'm working on has Windows account information in a domain database out of my control. Consequently, chsh is no longer supported.

I also found that bash is not hard-coded into the startxwin script, nor is it hard-coded in any .bat file. Turns out you don't need to fiddle with .bat files at all.

Searching for how to change my shell, I found some advice about mkpasswd

I added it to the mix.

The man-page said:

SYNOPSIS
   mkpasswd [OPTIONS]...

OPTIONS
   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.

   -c,--current
          Print current user.

  DESCRIPTION
        The   mkpasswd  program can be used to create a        /etc/passwd
   file.  Cygwin doesn't need  this  file,        because  it  reads  user
   information  from  the Windows account databases,       but you can add
   an  /etc/passwd file, for instance       if your machine is often  dis‐
   connected from its domain controller.

        Note  that this information is static, in contrast to the informa‐
   tion       automatically gathered by Cygwin from  the  Windows  account
   databases.  If        you  change  the user information on your system,
   you'll need to regenerate       the passwd file for it to have the  new
   information.


        For  very  simple needs, an entry for the current user can be cre‐
   ated       by using the option  -c.

(I don't know why the spacing is so "off"...)

I then used the following command:

mkpasswd -c | sed -e 'sX/bashX/zshX' | tee -a /etc/passwd

The next time you open a Cygwin Terminal, it will go straight to zsh

And that, I think, is what you asked for.

share|improve this answer

I just add the bin directory in the cygwin directory to my Windows Path Environment Variable and then either create a shortcut to:

mintty.exe -i /Cygwin-Terminal.ico zsh --login

or just change the default cygwin start menu shortcut to the same.

share|improve this answer

Just thought I'd add this answer in case it helps anyone who's looking for it. If you use chere (which adds a "Bash prompt here" option to the right-click context menu of any folder), you can set it to zsh ("Zsh Prompt Here") with:

chere -i -t mintty -s zsh
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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