Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set fish as "default" shell #2199

Closed
iamdevlinph opened this issue Jun 8, 2017 · 24 comments
Closed

Cannot set fish as "default" shell #2199

iamdevlinph opened this issue Jun 8, 2017 · 24 comments

Comments

@iamdevlinph
Copy link

iamdevlinph commented Jun 8, 2017

Your Windows build number:
Microsoft Windows [Version 10.0.15063]

What you're doing and what's happening:
Cannot set fish as default shell

I've tried

  • C:\Windows\System32\bash.exe ~ -c fish
  • C:\Windows\System32\bash.exe ~ -c /usr/bin/fish

When I run Ubuntu on Windows it's just a blank screen.

What's wrong / what should be happening instead:
When starting Ubuntu on Windows the default shell right away should be fish

C:\Windows\System32\bash.exe ~ -c /usr/bin/fish works in my other pc. But I forgot at what build I installed wsl (I'm already in the fast ring).

EDIT 1
Trying to reinstall.

EDIT 2
Didn't help

EDIT 3
Also tried adding

ssh-agent fish
exit

on top of ~/.bashrc as stated here

@iamdevlinph iamdevlinph changed the title Cannot set fish as default shell Cannot set fish as default shell using shortcut parameter Jun 8, 2017
@iamdevlinph iamdevlinph changed the title Cannot set fish as default shell using shortcut parameter Cannot set fish as default shell Jun 8, 2017
@sunjoong
Copy link

sunjoong commented Jun 8, 2017

@iamdevlinph
Copy link
Author

It's not really setting fish as default, per se. Rather, having bash run -c /usr/bin/fish/ on start up. Just in the first link you provided. But I haven't tried setting it with %systemroot%\system32\bash.

I will try it first and also the script in the .bashrc

@iamdevlinph
Copy link
Author

iamdevlinph commented Jun 9, 2017

I tried adding

# Launch Fish
if [ -t 1 ]; then
exec fish
fi

But when I start Bash it's just stuck in Welcome to fish, the friendly interactive shell

Same result with

if [[ -t 1 && -x /usr/bin/fish ]]; then
    exec /usr/bin/fish
fi

@iamdevlinph iamdevlinph changed the title Cannot set fish as default shell Cannot set fish as "default" shell Jun 9, 2017
@sunjoong
Copy link

sunjoong commented Jun 9, 2017

It's not really setting fish as default, per se.

@iamdevlinph - Yes. I said "You cannot set other shells except bash to DEFAULT shell". I think... you want a NEW feature to bash.exe.

But when I start Bash it's just stuck in Welcome to fish, the friendly interactive shell

It looks like rather "bash -c fish hanging indefinitely" than "Cannot set fish as default shell", I guess.

UPDATE: bash.exe on the current public release version of WSL cannot launch user defined DEFAULT SHELL, but wsl.exe on preview Insider builds version could do, I heard. So, use Insider builds or wait until public relase if you want to user defined default shell.

@iamdevlinph
Copy link
Author

@sunjoong I see. Thanks for the update.

Closing this one, I guess.

@benhillis
Copy link
Member

In recent insider builds you'll find a binary called wsl.exe which will respect the default shell in your /etc/passwd file. You can change your default shell via the chsh command.

@iamdevlinph
Copy link
Author

iamdevlinph commented Jun 9, 2017

@benhillis Uhh. So the part will respect the default shell in your /etc/passwd file. is not to be worried about, right? Just have to run chsh -c fish and that's it?

@benhillis
Copy link
Member

benhillis commented Jun 9, 2017

Correct, except you'll have to supply the full path to the fish binary. Then the next time you launch wsl.exe it will run fish. Bash.exe will continue to launch /bin/bash.

@iamdevlinph
Copy link
Author

Alright. So chsh -c /usr/bin/fish it is then.

Thanks

@RichieRock
Copy link

For me chsh -c /usr/bin/fish didn't do the trick since I couldn't find wsl.exe that @benhillis mentioned (do I have wrong version of bash for windows installed?). Whenever I start Bash on Ubuntu on Windows, only bash starts.

But I found another workaround:

Just add command fish in the end of your ~/.bashrc file. It will run fish whenever bash starts.

@iamdevlinph
Copy link
Author

iamdevlinph commented Oct 4, 2017

wsl.exe is currently available in the Fall Creators Update which you can get by being an Insider.

Just add command fish in the end of your ~/.bashrc file. It will run fish whenever bash starts.

This workaround isn't that efficient since it still runs your bash. As far as I know.

@aaronpowell
Copy link

I've been grappling with this too, I'm on Slow Ring Insiders so running something close to Fall Creators Update.

I get hit-and-miss when trying to get fish working as my default shell, sometimes it works, sometimes it doesn't, and there seems to be no rhyme or reason as to why it goes one way or the other.

The solutions I've tried are:

  • modifying my .bashrc to launch fish
    • both with the if guard and without
  • using chsh to change my default shell
  • launching with Ubuntu.exe -c 'fish'

My solution now is that I'll just launch with bash and then type fish once I get in there.

@iamdevlinph
Copy link
Author

Adding fish in the .bashrc should work, supposedly. Since it will call fish after calling bash.

But all the other solutions you tried will not work with the current bash.exe file. The new one though, wsl.exe, reads a file of some sort where the the shell you set using chsh is stored.

@iamdevlinph
Copy link
Author

td:dr; chsh commands will not work as long as you're no in the Fall Creators Update.

You'll need to have the wsl.exe, which is in the same directory as bash.exe. wsl.exe reads a file where your default shell set by running chsh is saved.

So options are to wait for the Fall Creators Updated to get to release and manually run fish. Or opt in to Insders Preview.

@aaronpowell
Copy link

I'm not actually using bash.exe but instead Ubuntu.exe as I'm installing the WSL instance via the store (which is becoming available with FCU)

@iamdevlinph
Copy link
Author

iamdevlinph commented Oct 5, 2017

Ohh. That's new to me.

I have the Fall Creators Update on my laptop but I installed WSL using the command line and it got me the wsl.exe file.

So maybe default shells only work with the wsl.exe file or something?

@benhillis
Copy link
Member

Chsh will also work with Ubuntu.exe, opensuse, etc.

@aishalih
Copy link

So is there any update nowdays, I kinda tried the stuff above, but currently my solution is like @benhillis said.

@endolith
Copy link

So, two years later, is there any update?

@iamdevlinph
Copy link
Author

I'm now using zsh instead of fish. And I'm using the Ubuntu from the Windows store.

chsh -s $(which zsh) worked for me out of the box.

@endolith
Copy link

I tried it multiple times yesterday with no luck, but today it worked. Nevermind.

@mohityadav7
Copy link

If you are using Windows Terminal, you can just pass fish to wsl.exe as an argument in the 'Command Line' option.
eg. C:\WINDOWS\system32\wsl.exe -d Ubuntu-20.04 fish. It worked for me 🥳

@VArterJr
Copy link
Member

VArterJr commented Jul 26, 2022

I know this is an old thread, but for those still dealing with this (like me... even on the current Preview version of WSL), chsh (even with sudo) doesn't work. @benhillis had mentioned /etc/passwd and editing it directly really has been the solution that works best for me (vs. launching fish or zsh or whatever from somewhere else). Just edit the /etc/passwd file and change the default shell in there for the user that wants fish (zsh, etc.) and it works perfectly.

@jonahfang
Copy link

@VArterJr . Thanks, it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants