Getting the Shell back on WSL

I have been using Linux more and more, via WSL, and learning a lot along the way.

Part of the jorney is breaking and fixing things, which is exactly what happened to me today.

I was trying to get the very nice command prompt, like the one from Scott Hanselman, and at some point following different steps from the ones shared by Scott I installed zsh as my shell.

After trying the zsh approach and not being able to make it work, I decided to revert, and stick to what Scott did, so first thing was removing zsh,

sudo apt-get remove zsh

And then when trying to get the prompt again all I got back was

process exited with code 1

Very bad

A similar GitHub issue provided some tips, none of which fixed my problem, but this particular comment set me in the right path, by running

wsl --user root

With it I was able to get the bash prompt back, and from there try to fix whatever was broken. Since something was failing while starting the shell, after removing zsh, I looked into the .bashrc and .zshrc files, removed them, but no change.

Then a response to my comment on github cleared everything up, “either apt install zsh or modify your users shell with chsh”

So I was able to interact as root, since root was still using bash, but my user was still configured to use zsh, and since I removed it that’s why it wasn’t working, and to change the shell? That’s where the chsh command comes to the rescue.

So running

chsh -s /bin/bash myLinuxUsername

Fixed the bash prompt

Now, back to customizing the prompt but without zsh, I revisited Scott’s post, and then I needed to add some lines to the .bashrc file, but I deleted that one while troubleshooting earlier.

Luckily I found this reddit comment

And sure enough, the default .bashrc was available at /etc/skel so I just went there and did a

cp .bashrc ~/

And back on track to get my prompt as fancy as Scott’s, and of course back at being productive with WSL.