Set Alacritty as the Default Terminal in Ubuntu
For Linux users, the terminal is a frequently used application, and using shortcut keys to quickly access it is essential. The default shortcut key in the Ubuntu Gnome environment Pressing Ctrl+Alt+T launches gnome-terminal. Since I prefer alacritty, I need to change my default terminal software.
1. View the default terminal shortcuts for the Gnome environment
Open Settings and search for shortcuts. You may not want to use the shortcuts shown below, but the default ones are easy to remember and don't require customization. I personally recommend using them.
2. Set the default terminal
Change the default terminal using
1sudo update-alternatives --config x-terminal-emulator
After running this command, I found that alacritty was not in the list of candidates. This is because alacritty was not installed using apt install alacritty
. A direct installation using cargo install alacritty
won't perform the associated operations. I suspect this is because.
1➜ ~ sudo update-alternatives --config x-terminal-emulator
2
3There are 4 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).
4
5Selection Path Priority Status
6------------------------------------------------------------
7* 0 /usr/bin/terminator 50 auto mode
81 /usr/bin/gnome-terminal.wrapper 40 manual mode
92 /usr/bin/terminator 50 manual mode
103 /usr/bin/tilix.wrapper 30 manual mode
114 /usr/bin/xfce4-terminal.wrapper 40 manual mode
12
13Press <enter> to keep the current choice[*], or type the selection number:
3. Add alacritty to the candidate list
- First check the alacritty installation path
1➜ ~ which alacritty
2/home/mephisto/.cargo/bin/alacritty
- Add to candidate list
1sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /home/mephisto/.cargo/bin/alacritty 50
/home/mephisto/.cargo/bin/alacritty
is the path to the alacritty command, and 50 is the priority.
Below are the steps. First, add the target to the list, enter 1 to select it, and press Enter. When you check again, you'll see that it has taken effect. Press Ctrl+C
to exit.
1➜ ~ sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /home/mephisto/.cargo/bin/alacritty 50
2➜ ~ sudo update-alternatives --config x-terminal-emulator
3There are 5 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).
4
5Selection Path Priority Status
6------------------------------------------------------------------
7* 0 /usr/bin/terminator 50 auto mode
81 /home/mephisto/.cargo/bin/alacritty 50 manual mode
92 /usr/bin/gnome-terminal.wrapper 40 manual mode
103 /usr/bin/terminator 50 manual mode
114 /usr/bin/tilix.wrapper 30 manual mode
125 /usr/bin/xfce4-terminal.wrapper 40 manual mode
13
14Press <enter> to keep the current choice[*], or type selection number: 1
15update-alternatives: using /home/mephisto/.cargo/bin/alacritty to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in manual mode
16➜ ~ sudo update-alternatives --config x-terminal-emulator
17There are 5 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).
18
19Selection Path Priority Status
20------------------------------------------------------------------
210 /home/mephisto/.cargo/bin/alacritty 50 auto mode
22* 1 /home/mephisto/.cargo/bin/alacritty 50 manual mode
232 /usr/bin/gnome-terminal.wrapper 40 manual mode
243 /usr/bin/terminator 50 manual mode
254 /usr/bin/tilix.wrapper 30 manual mode
265 /usr/bin/xfce4-terminal.wrapper 40 manual mode
27
28Press <enter> to keep the current selection [*], or type the selection number:
4. Confirm
Press the Ctrl+Alt+T
shortcut to confirm that alacritty pops up successfully. If nothing goes wrong, the system will run a process named x-terminal-emulator
(not alacritty).
1➜ ~ ps -ef |grep term
2mephisto 191336 5110 1 17:01 ? 00:00:01 x-terminal-emulator
Curious user, check what x-terminal-emulator is, as shown below:
1➜ ~ which x-terminal-emulator
2/usr/bin/x-terminal-emulator
3➜ ~ file /usr/bin/x-terminal-emulator
4/usr/bin/x-terminal-emulator: symbolic link to /etc/alternatives/x-terminal-emulator
5➜ ~ file /etc/alternatives/x-terminal-emulator
6/etc/alternatives/x-terminal-emulator: symbolic link to /home/mephisto/.cargo/bin/alacritty
7➜ ~ ls -al /usr/bin/x-terminal-emulator
8lrwxrwxrwx 1 root root 37 Apr 22 2022 /usr/bin/x-terminal-emulator -> /etc/alternatives/x-terminal-emulator
9➜ ~ ls -al /etc/alternatives/x-terminal-emulator
10lrwxrwxrwx 1 root root 35 Jan 9 16:32 /etc/alternatives/x-terminal-emulator -> /home/mephisto/.cargo/bin/alacritty
You can see that x-terminal-emulator
is soft-linked to /etc/alternatives/x-terminal-emulator
, which in turn is soft-linked to /home/mephisto/.cargo/bin/alacritty
.
The sudo update-alternatives --config x-terminal-emulator
command essentially creates a symbolic link for you according to the system specifications, ultimately pointing to your target terminal. The update-alternatives
command handles this task (see man update-alternatives
for documentation): update-alternatives - maintain symbolic links determining default commands
5. Rolling Back a Delete
What if I regret a deletion? How do I roll back a deletion?
1sudo update-alternatives --remove "x-terminal-emulator" "/home/mephisto/.cargo/bin/alacritty"
Similar to adding a component, if you can install it, you can also remove it, making it easy to do so.
Copyright statement:
- All content that is not sourced is original., please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).
See Also:
- Ubuntu 22.10 connection bluetooth headset error 'br-connection-profile-unavailable solution'
- alacritty can't input Chinese and the title bar problem
- Ubuntu install WeChat
- Ubuntu connects AirPods headphones
- alacritty terminal use
- Batch Convert PNG Images to WebP
- CopyQ Simple Use