Install Alacritty Terminal For Macos

February 5, 2018

I’m a huge Vim fan and using it since 2002 (the year I’ve started to learnLinux and how to compile Gentoo kernel). It’s a fundamental part of my life.But lately, I’m very sad about the performance on macOS terminals (iTerm2 andTerminal.app). On Linux, vim is literally flying, but on macOS, Vim renderingis very slow and lagging.

To build the Alacritty terminal emulator on Linux, run the command below while still in the Alacritty directory. Cargo build -release. Set desktop entry. For adding applications to device menus, most Linux and BSD distributions support desktop entries. The commands below will install the Alacritty desktop entry. Alacritty feels stable as a rock, and the performance is off the charts. The only thing that was missing was the sweet Guake-style terminal that I had gotten used to with iTerm2, I'm totally dependent on being able to bring up a terminal on any screen with a keyboard shortcut. The easiest way to install fish, complete with easy-to-remember URL. Webinstall.dev / fish fish is a smart and user-friendly command line shell for Linux, macOS, and the rest of the family.

This wasn’t always the case though. Some of the older version of iTerm2’srendering was fast. I know it was fast. But with each macOS update and iTerm2update, it would either get fast or slow. Some versions work decent, some don’t.And I didn’t want to stuck with an older version as well, as the newer versionof iTerm2 always has a lot of bug fixes.

After upgrading to a new machine (iMac Pro), I thought it would be much fasternow that I have a beast under me. But nope :) Things don’t work like that. Thiswas really frustrating. Upon some research, I’ve found my answer.

GPU accelerated terminal

I’m not alone. There are also other people who are not happy with current stateof emulators. Joe Wilm decided to change it and started theproject “Alacritty”.

Alacritty, is a cross-platform, GPUaccelerated terminal emulator written in Rust. It is focused on simplicity andperformance and therefore it’s very opinionated, but at the same time also veryambitious. Time will tell how Alacritty will end up, but I see already that ithas a lot of fans. What makes Alacritty so different from others?

Obviously, GPU accelerated rendering is the biggest selling point (usingOpenGL). However, it’s very opinionated as well:

  • It aims to be the fastest terminal emulator available everywhere. This isdone mainly by using custom written, fast parsers in Rust with advancedtechniques (such as table-driven parsing and using zero-cost abstractions inRust)
  • Simplicity is one of the core values of Alacritty. This means there is no GUIto change the configuration, no pane/window handling (no tabs orvertical/horizontal splits), no scrollback, etc.. The list goes on. Instead,one has to use something like Tmux to include all these features. Thissurprisingly works really good. However, there is an open PR that implementsscrollback, so things canchange regarding the focus towards simplicity.
  • Appearance is another important part of Alacritty. One difference I could seeis that with my new iMac Pro, the display supports the P3 color gamut. iTerm2uses sRGB, whereas Alacritty uses the system color profile. The colors aremuch more vibrant in Alacritty.
  • Alacritty is cross-platform. It aims a support for Linux, macOS, and Windows.

The author wrote a blog post that goes over these in more detail. Worth readingit: Announcing Alacritty

Install Alacritty

There are no binaries to install, from the author’s words:

Precompiled binaries will eventually be made available on supportedplatforms. This is minimally blocked in a stable config format. For now,Alacritty must be built from source.

So how do you build from the source? This is all written in theREADME.mdfile. I didn’t find the README.md very useful as the steps for macOS is allover the place. Here is a recap for you:

First, you need Rust to compile and build Alacritty. The easiest way toinstall rust is to to use the official toolchain installerrustup.rs. Execute the following line to install rust:

(note: Kudos to the Rust team to great an easy to install experience for rusttoolchain, but I have to say that Go’s native macOS dmg installer feels moresecure)

All rust related binaries will be installed to .cargo/bin. Make sure to addit to your PATH:

Finally, make sure you have the right Rust compiler installed:

And then git clone Alacritty and start compiling the macOS app:

Once this is finished, you’ll get a ready to use Alacritty.app file. Copy itto /Applications and you’re done!:

But, don’t start Alacritty yet. There are couples of configuration steps worthtalking. Let’s do them.

Install Alacritty Terminal For Macos

Configure Alacritty

There is a ready to use configuration file in Alacritty for macOS. Copy it tothe configuration folder of Alacritty (be sure to be inside the git repo):

Now when you start Alacritty, it should start with this base configuration.We’re not finished yet as I’ve customized it a little bit for my need. What arethese?

First I’m using the SF Mono fonts:

I don’t like pure black background because it hurt my eyes. I, therefore, use aslightly less muted background. I also like a red cursor block:

Alacritty install

I don’t want to see my cursor when I use the terminal, so I disable showing thecursor it with:

My shell is set to zsh. We have to tell Alacritty explicitly which shell weuse:

Lastly, I don’t use cmd+w to close a window (we’re going to use it forsomething else). Therefore I deleted the following line from key_bindings:

Those are the main parts in my configuration. I’m still discovering new thingsand updating my alacritty.yml file from time to time. Be sure to follow mydotfiles repo to see the latest changes:https://github.com/fatih/dotfiles/blob/master/alacritty.yml

We’re still not finished though. The key_bindings field is interesting thatit allows us to capture any shortcut and execute certain commands. We can evenwrite escape sequences for certain shortcuts. This is very powerful because itallows us to customize Alacritty even further if used with tmux.

Make Alacritty feel like iTerm2

I like iTerm2 and using heavily the split/verticalpanes, tabs, resizing the panes etc.. features of it. It’s heavily customizedfor my needs. As I said, Alacritty doesn’t support any of the bells andwhistles. But it can be configured to send escape sequences (in hex code) foryour custom shortcuts.

Before we dive into this, note that I use tmuxfor managing my views. tmux is very powerful, so you can do a lot of thingswith it. You can see my tmux configuration file in my dotfiles repo:tmux.conf

All terminal multiplexers/applications have their own terminology. In tmux this is:

  • session: a collection of terminals that tmux handles. Each session has one more window
  • windows: a window occupies the entire screen. It can be split into rectangular panes
  • panes: the smallest unit in a window. One or multiple panes

This is kinda the same in iTerm2, except windows is called tabs. I’m usingtabs and panes heavily in iTerm2 with shortcuts (no mouse is used), such as :

  • create/close a new tab
  • create vertical and horizontal pane
  • increase/decrease size of panes
  • jump between tabs directly
  • move between panes easily

I can do all these actions with tmux as well. But not with the same shortcuts.For example, if I want to open a new vertical pane, I have to type the following:

This means, you first press ctrl and f together, and then press v. Forhorizontal split, I use the following:

Same, for the steps above I have to use these shortcuts in tmux (I’ve manuallychanged some of them to my own liking):

  • create a tab: ctrl-f c
  • close a tab: ctrl-f &
  • close a pane: ctrl-f x (this also closes the tab if there is a single pane)
  • create vertical pane: ctrl-f v
  • create horizontal pane: ctrl-f s
  • move between panes: ctrl-f h, ctrl-f j, ctrl-f k and ctrl-f l
  • resize panes: ctrl-f H, ctrl-f J, ctrl-f K and ctrl-f L
  • jump to specific tab: ctrl-f <number>, i.e: ctrl-f 3

However, I use a completely different shortcut set under iTerm2:

  • create a tab: cmd + t
  • close a tab: cmd + w
  • close a pane: cmd + w
  • create vertical pane: cmd + d
  • create horizontal pane: cmd + shift + d
  • move between panes: cmd + h, cmd + j, cmd + k and cmd + l
  • resize panes: cmd + left, cmd + right, cmd + up and cmd + down
  • jump to specific tab: cmd + <number>, i.e: cmd + 3

Now the question boils down how to use these shortcuts in tmux? As I said,Alacritty can be configured to send escape sequences (in hexcode) for yourcustom shortcuts.

So, for example, you can send a hex code that represents the key combinationctrl-f v which in my case opens a vertical pane. The hex code for thiscombination is: 0x06 0x76. There are many ways to find out how to obtain these hex codes. One of themis the tool xxd. xxd is a tool that creates a hex dump of a given fileor standard input. This is very useful because escape sequences we set inAlacritty needs to be presented in hex codes.

From your terminal, if you run xxd -psd and press ctrl-f v and then enter andfinally ctrl-c to exit, it outputs the following:

What matters is the sequence 06760a^C. Let’s split it every two characters:

From here, we know that 0x06 0x76 corresponds to ctrl-f v. This is the mostimportant part. Once we have this, we can now tell Alacritty to use this escapesequence code. Remember that I use cmd + d to open a vertical pane, now we’regoing to tell Alacritty to invoke the above escape sequence whenever we usecmd + d inside Alacritty:

To do this, we need to add a line to key_bindings field in alacritty.yml:

That’s it! Now whenever you press cmd + d inside Alacritty, this willautomatically be transformed into the escape sequence x06x76 which then opensa vertical tab in tmux.

Once you have this done, we need to add all other shortcuts as well. This isthe only time-consuming part because you have to call xxd for each tmuxshortcut to obtain the hex code. Let me know if you know if there is an easierway to do it (maybe an ASCII table?)

The followings are the ones that I’m using:

Install Alacritty Terminal For Macos

Finally here is my full configuration I use for Alacritty in my dotfiles repoif you’re interested:alacritty.yml

Final words

I’m using now Alacritty for a while and I really like it. I still need to getused to the combination of using tmux with Alacritty. There are couples ofrandom things that I have to mention though:

  • Copy/paste is still a hassle for me. Selecting with mouse is possible, but Ihave to press y before I release my selection with mouse. This is reallyawkward. Because of that, I’m using more and more the vim-copy mode intmux. This allows me to copy the text without using the mouse. It’s not thebest for me right now, but let’s see if this is something I can live with.
  • If you resize Alacritty (say with mouse), the content disappears until theresizing is finished. This is a known bug(https://github.com/jwilm/alacritty/issues/869) and the fix is to disabletransparency if you use High Sierra. There is no setting in theconfiguration, so I’ve recompiled Alacritty by disabling transparencyin src/windows.rs:

Alacritty For Mac

  • There is another weird bug that only happens when I focus on Alacritty byclicking with the mouse. In this case, the statusline of Vim suddenly jumpsto the middle of the screen. When this happens there is no way I can fix itfrom the keyboard. I’ll update the blog post when I find a solution for this.
  • Alacritty is a fairly new project compared to other terminal applications. Ithas a lot of edge cases, so don’t seek short-term stability for now
  • I can click on any URL with mouse in iTerm2 (with alt key) and it would open it in abrowser. This is not possible with tmux+alacritty. However, there is a pluginin tmux that enables this with keyboard shortcut: https://github.com/tmux-plugins/tmux-open
  • The author of iTerm2 started to implement GPU-based renderer as well andit’s merged to master. This means you can download the nightly iTerm2 andhave the same speed benefits. Here is how you can do it:https://gitlab.com/gnachman/iterm2/wikis/Metal-Renderer#how-to-test-it
  • Alacritty looks beautiful on my iMac Pro’s display because it uses the System(P3) color profile. iTerm2 doesn’t do this, therefore the colors look dulland are not vibrant as Alacritty. There is an openissue and the author ofiTerm2 aims to fix it.

I’m going to use Alacritty for a foreseeable future, however, I’m not closingthe doors to iTerm2 either. With time I’ll see if I can live with Alacritty ornot.

Finally, I want to thank Cihangir Savaşand for his much valuable feedback and suggestions.

If you have any questions or feedback, please feel free to share them with me on Twitter: @fatih

Alacritty, the nihilist terminal setup

Alacritty is a suckless terminal emulator written in Rust, it’s extremely fast and very simple. Here’s how to install and configure it.

What is a suckless program?

Software with a focus on simplicity, clarity, and frugality.

Meaning, for example, that Alacritty will never 'call home' to gather telemetry, aka track you. It will never haze you with automated update notices. There’s no package manager, there’s no GUI for settings, nor for menus, it doesn’t have tabs, there’s nothing... just a void of pure, unadulterated nihilism.

This either sucks less, or sucks more, depending on your personality.

Install Alacritty on Mac OS

I’m on Mac, so this install guide is Mac-centric, but see the Alacritty repo for more installation instructions.

Since Alacritty is a GUI app (icon in the Applications directory), in Homebrew-land this means it’s a 'cask', and has to be installed with the --cask flag:

The --no-quarantine option is needed because Alacritty isn’t part of the Apple developer program. Otherwise you might get this error:

Check your version with the capital V:

And upgrade Alacritty if needed:

Setup terminfo

From the docs:

To make sure Alacritty works correctly, either the alacritty or alacritty-direct terminfo must be used. The alacritty terminfo will be picked up automatically if it is installed.

I’ve used Alacritty successfully without terminfo, though.

Test if you got terminfo installed:

Clone Alacritty because we need bits from it, and hop into the dir:

Then setup terminfo:

Configuring Alacritty

Config is done with a YAML file that lives in ~/.config/alacritty/alacritty.yml. This is great, because now you can keep the config in your dotfiles and share it between machines, which you can’t do with iTerm for example.

My config is pretty default, but I’ve cherry picked few things to highlight here. See the full config below.

Copying with mouse

Copy the selected text to system clipboard without having to press Cmd/Ctrl+c:

Remapping alt for your keyboard layout

This mapping is for British keyboard layout. This is needed so that you can type hashes in Vim for example, which is Alt+3.

See this thread in GitHub for more examples. And a this Wiki entry for more keyboard configs for layouts like German, Swiss, Italian, Spanish, Portuguese...

Handle fish shell

If you’re on fish, tell Alacritty about it:

Get the path to your fish with $ which fish.

Then set the fish completion by grabbing the alacritty.fish completion mapping from the Alacritty repo we cloned earlier:

Clickable URLs

Make URLs clickable when Cmd is held down:

But why can’t I click URLs even if I have configured it the right way? You might be in a tmux session and have the mouse mode enabled, which captures clicks before Alactitty can see them. The mouse mode can disabled by pressing Shift, so Cmd+Shift click, should work.

Color themes

See a selection of color themes in the Alacritty repo.

Full config file

This is my full config at the time of writing this:

See all the options in the freshest config file on the releases page in Alacritty GitHub.

Keyboard shortcuts

Here’s the default ones on Mac:

KeyCommand
Cmd+0ResetFontSize
Cmd+EqualsIncreaseFontSize
Cmd+PlusIncreaseFontSize
Cmd+MinusDecreaseFontSize
Cmd+KClearHistory
Cmd+VPaste
Cmd+CCopy
Cmd+CClearSelection
Cmd+HHide
Cmd+MMinimize
Cmd+QQuit
Cmd+WQuit
Cmd+NSpawnNewInstance
Cmd/Ctrl+FToggleFullscreen
Cmd+FSearchForward
Cmd+BSearchBackward

You can’t pull down 'File' and choose 'New Window', but there’s a default keybinding spawn an new instance Cmd+N. That can be remapped to Cmd+Shift+N for example, with the pipe | you can add modifiers:

The Vi mode

Alactitty has Vi mode. Meaning: you can navigate the prompt with hjkl like in Vim. You can turn the Vi mode with Ctrl+Shift+Space, and exit the Vi mode with the same shortcut.

To copy text in Vi mode, press v and highlight the text you want, then press y (yank) to copy it to your systems clipboard. You can also use mouse to copy text like a normal person.

Using Alacritty

It’s a terminal emulator, so you don’t really use it, you use other programs with it. But you can issue the alacritty command, which will pop out a new window:

You can also start a new Alacritty session using a different config file:

Check the help to see all the flags and options:

Juice it up with Tmux

Since Alacritty is so frugal with features, you really need Tmux (or screen) to go with it.

Install Alacrity Terminal For Macos Sierra

I have a full post about tmux which has all the good stuff.

Install Alacrity Terminal For Macos X

Read more:How to install and use tmux

But below is the really basics.

Install:

Pop open a tmux session:

Install Alacritty On Mac

Tmux is all about the keyboard shortcuts, everything starts with a Ctrl+b then followed by a key. For example Ctrl+b % splits your pne into two. Ctrl+b c opens a new window (analogous to a tab). Ctrl+b n goes to the next window, Ctrl+b p to the previous. Check out my above mentioned post about tmux for more details.

Conclusions

Alacritty is pretty easy in the sense that you set it and forget it, it doesn’t need much attention. It took me a while to figure out tmux, though. But tmux is a good program to know, you can carry that knowledge over to other environments.

Install Alacrity Terminal For Macos Operating System

And by the way; even tho I say it’s 'nihilist', I really love Alacritty ❤️

Comments are closed.