If you're looking to use Bash on Windows in 2020, you're likely to see a lot of articles about Windows Subsystem for Linux (WSL) and the second version that has recently been released. This isn't about that.
You see, coming from Mac and Linux backgrounds I have always been underwhelmed by the Windows terminals. For a long time now we've been able to use "Git Bash" which works fine in terms of running the same commands that I've been used to for years. But it has never felt nice to use, the keybindings are all odd and the customisation is limited.
So I was quite excited when they announced the new Windows Terminal (which you can download from the Windows Store). When I first tried it, I could see it was nicer to use but quickly realised most articles explained how to use it for Powershell or WSL. I'm sure WSL is brilliant but it's better for doing Node.js kind of work, I use my Mac whenever I do that. So I gave up and continued using Git Bash with the mild frustration I've always experienced with it.
That was until I got a tweet from Rich Turner explaining how to add a new profile. Now, I'm sure I did the exact steps he mentioned when I first tried... I know I got bash running in some way but it felt very hacky and not good. I don't know what I did originally but I do know how I got it working well. I haven't got it set up yet with all the same customisations as I have on Mac but it does now work well as a basic terminal without any of the frustrations I've always had when using Windows for development work.
To add Bash to the Windows Terminal you need to add a profile (essentially an object to an array) in the settings JSON file. I followed a Stack Overflow answer but will briefly note how to do it here.
ctrl + ,(or the triangular menu at the top then Settings). This will open a text editor showing the settings JSON file.
profilesobject with an array called
listinside it. You will want to add the profile for Bash inside this array.
"commandline": "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
"padding": "5, 5, 5, 5",
I'm sure PowerShell is great, but it's not my shell of choice (on Mac I use zsh). Thankfully with Windows Terminal it allows us to set whichever shell you want by setting the
defaultProfile at the root level of the settings JSON to be the GUID of your chosen profile. Given it is default profile not default shell, this could be taken further to have multiple customisations with one as your default.
It's really useful to be able to define your own keybindings, especially when going between two Operating Systems. I have kept it very light for now, so I've only changed settings to fix the frustrations I've had in the past with terminals on Windows. I'm sure there's far more interesting things that can be done!
When I started using Windows Terminal (and indeed the first time I tried and failed to use it) one of my annoyances was the lack of sensible copy/paste keybindings. I am so used to Mac having
cmd + c and
cmd + v within the terminal that it's always been my main frustration with Git Bash it has weird bindings.
I was able to finally fix these in the settings file for Windows Terminal. But it turns out that recently version 1.0 was released, which has these as a default.
So chances are this is no longer an issue for people. But for anyone that is still on an older version, you can add these within the
keybindings array in the settings file:
It's really nice that Windows Terminal has tabs... but it is quite weird that the default keybinding for new tab is
ctrl + shift + t. Maybe it fits in better with shortcuts that Windows power users already use but for me I kept pressing the wrong buttons. I work mostly in the browser, so I've copied the new tab shortcut I use all the time in browsers
ctrl + t. Again, it's added to the
keybindings array in the settings file.
// Open New Tab
The purpose of a terminal is to barely notice it exists. It should just be the way you talk to the computer at one of the lowest levels possible. I'm happy that with these adjustments to Windows Terminal (and with even less required for the latest version) there is now a good way to use Bash on Windows. The old ways were fine but from puTTY to Git Bash, it never felt the same as using Mac or Linux. Now it feels close enough and the WSL exists too so that's brilliant but for normal day-to-day activities like using Git it now just gets out of the way. The frustration is gone, I can get on with stuff now.