Skip to content

Instantly share code, notes, and snippets.

@aanari
Last active April 29, 2024 16:28
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aanari/08ca93d84e57faad275c7f74a23975e6 to your computer and use it in GitHub Desktop.
Save aanari/08ca93d84e57faad275c7f74a23975e6 to your computer and use it in GitHub Desktop.
Set Alacritty as Default Terminal Editor (Ubuntu)
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --config x-terminal-emulator
Copy link

ghost commented Mar 28, 2021

Thank you!

@mfdorst
Copy link

mfdorst commented Mar 30, 2021

Thanks for this.

What does the 50 at the end do?

Also, consider using $(which alacritty) rather than hard coding /usr/bin/alacritty. For me alacritty was installed somewhere else.

Copy link

ghost commented Apr 15, 2021

Thanks for this.

What does the 50 at the end do?

Also, consider using $(which alacritty) rather than hard coding /usr/bin/alacritty. For me alacritty was installed somewhere else.

Suppose you only have the default Ubuntu terminal installed in your system.

If you run sudo update-alternatives --display x-terminal-emulator you will see some information about the link group, in this case: x-terminal-emulator. One of that information will be the priority of the default Ubuntu terminal, which in my case is 40.

So setting the 50 at the end of the command will set the Alacritty terminal emulator with the highest priority in the link group, which means that will be selected by the system as the default terminal.

sudo update-alternatives --config x-terminal-emulator This command just updates the link group, so Alacritty will be automatically selected since it has higher priority.

@K1ngjulien
Copy link

I have alacritty installed with snap which made the setup process more difficult since to start alacritty you have to use the snap run alacrtty command. ( which alacritty will give /snap/bin/alacritty but that is just a symlink to the snap binary )

I created the following script in /usr/bin/start-alacritty :

#!/bin/sh

/usr/bin/snap run alacritty

And set/copied the permissions accordingly:

sudo chown root:root /usr/bin/start-alacritty
sudo chmod --reference=/usr/bin/ls /usr/bin/start-alacritty

Followed by the commands from above:

sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/start-alacritty 50
sudo update-alternatives --config x-terminal-emulator

Now ctrl+alt+t in Gnome finally launches the right terminal.

Hope this helps anyone who also "accidentally" installed alacritty through snap 😄. Thanks for sharing this tho, it gave me a good starting point.

@dav1d-wright
Copy link

@K1ngjulien Thank you, this helped me a lot! 🥇 👍

@emilBeBri
Copy link

yes very nice @K1ngjulien !! thx a bunch

@bodyguardcomnp
Copy link

thank you. Now how to set it back to default ?

@aanari
Copy link
Author

aanari commented Apr 29, 2024

Thanks for this.

What does the 50 at the end do?

Also, consider using $(which alacritty) rather than hard coding /usr/bin/alacritty. For me alacritty was installed somewhere else.

From the man page, this is the "priority" which is used for the following purpose - "when a link group is in automatic mode, the alternatives system ensures that the links in the group point to the highest priority alternative appropriate for the group." In other words if a decision needs to be made as to which link is used, the numerically higher value wins out.

Good suggestion - I updated the script to use $(which alacritty) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment