"Can you run Bash in Cmder?" - In the comments of my last post (install and run (Oh-my-) zsh on Bash on Ubuntu on Windows), I was asked whether it would be possible to run the Bash (or Zsh) also in Cmder. First I thought it was not possible, but then I got curious. After digging in a bit more it turned out that it IS, in fact, possible. And it's not difficult too.
So, since I figured out how it works, I also want to show you how you can run the Windows 10 Ubuntu Bash (and/or Zsh) in Cmder.
What is Cmder?
Cmder is a console emulator for Windows. It is my preferred way to use the Windows console (cmd.exe) for the last years, as it allows me to use *NIX commands like ls, less, grep and the like. For me, Cmder is a much nicer overall experience on the command line in Windows, and it makes me much more productive.
Cmder allows me to open multiple tabs and multiple shells at once. I can open a normal cmd.exe shell, a second one that also executed the VsDevCmd.bat file to provide access to msbuild, csc etc., a third one with powershell and, if set up correctly, also one with Bash and/or Zsh.
Actually, you just need Bash on Ubuntu on Windows enabled and, of course Cmder. If you don't have that, you can simply follow these instructions:
- Install Bash On Ubuntu on Windows
- Download and unzip Cmder to a convenient place on your disk. Then start Cmder.exe.
- Optionally, install (Oh-my-) Zsh on Bash on Ubuntu on Windows
Set up Bash in Cmder
First, in Cmder, you press Win + Alt + T to open up the settings dialog for Tasks. Alternatively you can open up the hamburger menu on the bottom right of the window and navigate to Settings -> Startup -> Tasks.
Step 1: You create a new Task by clicking on the '+' Button at the bottom and enter the details.
Step 2: The first input field of the dialog is the task name. I named it 'bash::ubuntu' but the naming is completely up to you. You can use double colons for grouping, so this would be the 'Ubuntu' task in the 'Bash' group. Cmder already comes with a 'Bash' group containing entries for Bash on mintty (using Cygwin) and another one based on on git-for-windows. To distinguish between the other Bashes and the 'real' Ubuntu thing, I simply chose to also opt into this naming scheme.
Step 3: In the "Task parameters" input you can configure an icon (I just picked the Ubuntu Bash icon):
Step 4: In the "Commands" input field, you enter the command that this task should start. This is the actual call to Bash:
%windir%\system32\bash.exe ~ -cur_console:p
This will start bash.exe in the current user directory (~), and also sets the cursor console mode of ConEmu, which works behind the scenes in Cmder, to allow for correct cursor movement with the arrow keys.
You can find further details on how to set up Tasks in Cmder (actually, in ConEmu) in the ConEmu documentation about tasks.
This task now will start the Bash on Ubuntu on Windows within Cmder, with all the settings you did in your .bashrc file.
Set up Zsh in Cmder
If you did not set up your Bash to automatically launch Zsh from your .bashrc file like I showed in the other blog post, you can add another task for this.
I called this new task 'zsh::ubuntu', but again the naming is up to you. I used the same task parameters as for the Bash task and just added
-c zsh to the command entry. This will cause Bash.exe to start Zsh automatically.
The full line is:
%windir%\system32\bash.exe ~ -c zsh -cur_console:p
5 Replies to “Running Windows 10 Ubuntu Bash in Cmder”
In cmder for bash/zsh will not work up/down (command history) 🙁
Thank you for posting this. I’ve been using mac OS for years and accustomed myself to a nice zsh console in iterm, but after getting a MS Surface as my main work-on-the-go machine I relegated myself to Ubuntu on Windows 10, not realizing a few simple configs could improve my life.
I was wondering if you’ve had any luck configuring up a powerline theme for zsh under this setup.
It requires fonts that I can’t seem to get to work in Cmder, so I wind up with a lot of Tofu looking characters instead of the icon features. Here’s links to these projects if you’re not already aware:
Nevermind, I got it working using by using the powerlevel9k theme downloading fonts patched with fontawesome icons! Again, thanks for the article.
This works well, thanks!
Comments are closed.