How I migrated from iTerm to alacritty
Alacritty — A cross-platform, GPU-accelerated terminal emulator
This is about one fine weekend, where I was tinkering with my Vimrc & exploring ways to optimize it further. Yes, I’m one of those people. One thing leads to another & I ended up on a stack overflow answer which leads me to alacritty https://github.com/alacritty/alacritty.
Being a productivity junkie, hearing the word — “fastest” just excited me right off the bat. I planned to give alacritty a try & here I am, a few days after, completely moved to alacritty. Since the process was tedious & there are a few things I explored on the way, here’s my take on making sure your migration to alacritty is as smooth as possible.
Here’s the WHY.
- Fast — It says it’s fast, & I perceived it as fast, you may say its placebo. Whatever, give it a try yourself.
- Configuration made for programmers— I loved how the full configuration is just a single file ‘alacritty.yml’ & the terminal can be configured just from that. I personally don’t like scanning through iTerm’s UI based configuration (I always forget where things are) & it’s difficult to port. Since I have an automated dotfiles setup, this just made my life even easier.
- Key bindings like never before — I’m a person who uses tmux as their multiplexer & for me iTerm was mostly doing the terminal part of it, never the multiplexing part. There are two problems I faced with iTerm:
* Key bindings with ‘command’ key were just not possible & iTerm has some of them mapped to their own bindings. With alacritty, I was surprised at how easy it is to map key bindings with ‘Command’ as a prefix, for example: <Command + ]> to move to the next tmux window.
* Copy to clipboard with VIM: iTerm’s feature of copying to clipboard on double click is something I love & use quite often, but when enabling cursor in vim which lets me scroll, just doesn’t play along with iTerm, VIM just takes control over it. With alacritty, this just worked like I wanted it to automatically, Now I have terminal clipboard goodness with VIM’s scroll. - Minimal & clutter-free — As soon as you install alacritty the first thing you’ll notice is the absence of any UI settings, it gives you just the terminal to work with & that is it. It doesn’t mean you lose out on either the amazing True color support while working with VIM or the performance. That’s where it really shines.
Here’s the HOW.
At the time of writing these are my system configurations:
OS — macOS Catalina
Multiplexer — tmux 3.1
Editor — Neovim v0.4.3
Step 1: Install with brew
brew cask install alacritty
The official docs also advise you to install the man page, shell completions. I personally didn’t require it, hence I didn’t install. If you’re interested, follow the following link: https://github.com/alacritty/alacritty#macos
Step 2: Setup terminfo
Terminfo is used by tmux & other programs to work properly. An example use case is, it helps enable those True color/Italic capabilities for your terminal.
# Clone alacritty
git clone https://github.com/alacritty/alacritty.git
cd alacritty# setup terminfo
sudo tic -xe alacritty,alacritty-direct extra/alacritty.info# cleanup
cd .. && rm -rf alacritty
Reference: https://github.com/alacritty/alacritty/blob/master/INSTALL.md#terminfo
An important step is to update your ‘tmux.conf’ & ‘.vimrc’ to make sure it utilizes the terminfo capabilities by doing so:
~/.tmux.conf
# Add true color & italics support with alacritty terminal
set -g default-terminal "alacritty"~/.vimrc
" Enable true colors if available
set termguicolors
colorscheme gruvbox
" Enable italics, Make sure this is immediately after colorscheme
" https://stackoverflow.com/questions/3494435/vimrc-make-comments-italic
highlight Comment cterm=italic gui=italic
This makes sure, you get all the True colors(if your theme supports it) & italics(if your fonts support this). Trust me, you’ll see a visual difference for the same VIM’s colors scheme in iTerm vs alacritty.
Step 3: Setup alacritty.yml
One very important thing to know is, alacritty doesn’t create a default alacritty file. I spent some good amount of time trying to get the default file but in the end, I ended up just taking alacritty.yml from the root of the repository. That’s a great starting point & it’s commented really well & you can just modify it based on your needs.
So create one at this location for alacritty to read it:
~/.config/alacritty/alacritty.yml
Here’s my sample configuration, with comments explaining each line item:
A few things to keep in mind:
- Make sure your fonts support ligatures/glyphs, if not rather look for another font that does support that or can be converted into one. For example, Operator mono fonts can be converted to support ligatures using: https://github.com/kiliman/operator-mono-lig
This is required for appropriately rendering the UI of tmux & VIM’s powerline. - To add key bindings using mac’s ‘command’ key follow this: https://arslan.io/2018/02/05/gpu-accelerated-terminal-alacritty/#make-alacritty-feel-like-iterm2
I’ve added a few convenient ones based on my muscle memory from iTerm, but do whatever feels natural to you. - When you change the line-height using offset: y, alacritty messes up the vertical alignment under the cursor. This is what I’m talking about:
Use the ‘glyph_offset’ to adjust the alignment.
Note: This property requires a restart for the changes to take effect.
Step 4: Enable font smoothing for Mac
This is to make sure that your fonts render crisp on that retina display:
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
Reference: https://github.com/alacritty/alacritty/issues/1635#issuecomment-523840350
Automated script
Here’s the automated script I use to set up the above-mentioned steps in one go:
Run it using:
./install-alacritty.sh
Note: You’ll still have to manually put the “alacritty.yml” file at the mentioned location in step 3.
Closing Note
And that’s it. It should get you going..! I’ve been using it for a few days now, & I don’t think I’m going back. Comment, if you face any issues & share your experience.
Head over to alacritty’s official docs in case you’re stuck somewhere: https://github.com/alacritty/alacritty
Here’s a link to my dotfiles if you’re interested: https://github.com/pezcoder/dotfiles