Leaving Cmder for Alacritty: 2020 Edition

Leaving Cmder for Alacritty: 2020 Edition

Since about 2017, I've been using Cmder almost daily as my console emulator of choice. There were a few key reasons why I gravitated towards it, and why it has stuck around for so long, but few issues have now led me elsewhere.

Would I still recommend Cmder?

After so many years of using Cmder, I actually still recommend it to newer analysts, people who migrate computers a lot, or folks who don't have administrative rights on their work computers. For anyone who is a little more settled in their development careers though, the question gets a little more complicated. Let's dive into some of the positives and negatives that in the end led to me searching for alternatives.

The Good

  • It had a portable version! This was especially important since I was not allowed to have admin rights on my work computer and wanted the same terminal console everywhere.
  • It came with git and ssh out of the box.
  • The default theme settings looked pretty good particularly in comparison to PowerShell or the Windows Command Prompt.
  • Clink and the Git aware prompt were new to me at the time and really interesting.

The Bad

You might be thinking this all sounds great! It has some handy features to make it feel more like Linux and required minimal configuration! What went wrong?

  • Speed - Cmder often feels slow. Really slow. Admittedly my work computer has a terrible hybrid drive which entirely negates the otherwise powerful machine, but when Windows Update runs in the background, I can barely open Cmder or run basic commands like ls. While admittedly not nearly as bad, it also feels slow on my home laptop and desktop even though they both have SSDs.
  • Settings Menu - Cmder offers a lot of customizability, but it presents so many options that I found it difficult to find what I wanted or to discover new features. As I got more comfortable setting up my own command line and dev tools, the sensible defaults that drew me to Cmder in the first place eventually led it to be a little more frustrating later on.

Enter Alacritty

Alacritty initally made waves on Hacker News back in 2017 for being a fast GPU-accelerated terminal emulator written in Rust. It was fast, but didn't have some basic features like tabs or scrollback. I initially dismissed it since it also did not have Windows support, but I came across it while searching for a Cmder replacement.

Many of the initial positives for Cmder did not matter to me any more, and Alacritty addressed the negatives too. The minimal configuration Alacritty offers is through a YAML file, but the options are all clear and there are few enough that it is easy to look them up. It feels fast, even when working with files quickly in VIM something that was especially annoying in Cmder. I needed to install Git and OpenSSH anyway for other tools, so it didn't bother me not having it built in. I finally knew enough to set up a Git aware prompt myself.

Configuring Alacritty

By default, Alacritty looks very plain out of the box.

Alacritty Defaults

For a full list of configuration options, see the example configuration file, with all options commented out. For now, creating the config file:

mkdir $env:APPDATA\alacritty
nvim alacritty.yml

I started out by setting up the window defaults, fixing the font, and introducing a hint of transparency.

window:
  title: SuperFun🚄
  dimensions:
    columns: 100
    lines: 30

font:
  normal:
    family: 'Source Code Pro for Powerline
 
background_opacity: 0.95

I also copied the gruvbox_dark theme colors from the Alacritty Themes GitHub page, since it is the theme I use for all of my other software.

Already we have an immediate improvement (in my eyes):

Alacritty with Source Code Pro, Transparency, and Gruvbox Dark

Next, let's introduce a few functional changes to make it easier to use on my laptop:

selection:
  # When set to `true`, selected text will be copied to the primary clipboard.
  save_to_clipboard: true
  
# Updating to PowerShell 7 (added to my PATH variable as pwsh)
shell:
  program: pwsh

# Paste text with right click, instead of the default middle mouse wheel
# click
mouse_bindings:
  - { mouse: Right, action: PasteSelection }

And that's it! If all you wanted was a fast terminal emulator, this is pretty much all there is to it. There is some remaining work to do though to make it look especially good and add back in a Git aware prompt.

Powershell, Oh-My-Posh and Posh-Git

Since Alacritty is just a terminal emulator, it still needs a shell to run inside it. Despite a pretty good experience with Clink in Cmder, I decided it was time to try out PowerShell. Microsoft has released it on MacOS and Linux too now, and honestly, I just felt like trying something new. Furthermore, WSL does not work well on my work computer, and WSL2 is not available on it yet at all. The new Windows Terminal looked interesting, but the Windows Store at work is limited to only a couple apps approved by the IT department, of which it is not one.

To make PowerShell look a little more attractive, you can install some Powerline fonts and Oh-My-Posh, a prompt theming engine for PowerShell (it was designed for ConEmu intially, but it works on Alacritty too).

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Then, if you add the four lines below to your PowerShell profile, it will auto-import everything as soon as you open Alacritty. Rather than finding the profile file, you can just nvim $PROFILE instead.

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Agnoster
$DefaultUser = $Env:UserName # Hide the username, since I only use one account

I didn't seem to need it, but if you are running the PowerShell Core, you will apparently need this too:

Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck

So what does this all this work actually result in?

Alacritty with Oh-My-Posh

I think it looks good! And more importantly, it is faster to load than Cmder (even with Anaconda and Oh-My-Posh), more responsive, and styled to my own preferences. Hopefully this inspired you to switch up your setup too!

P.S. You might need to initialize Anaconda in Powershell for environments to work correctly:

conda init powershell

Note that this will slow down your PowerShell boot time significantly (about 1.5 seconds for me on Powershell v7.0.1 on my laptop SSD). I have not figured out how to only load it when I run activate base unfortunately.