永久将 alacritty 设为默认终端

永久将 alacritty 设为默认终端

目前我使用alacritty作为默认终端仿真器。在任何一天,这是输出update-alternatives

$ sudo update-alternatives --config x-terminal-emulator
There are 7 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).

  Selection    Path                             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/alacritty                70        auto mode
  1            /usr/bin/alacritty                70        manual mode
  2            /usr/bin/gnome-terminal.wrapper   40        manual mode
  3            /usr/bin/koi8rxterm               20        manual mode
  4            /usr/bin/lxterm                   30        manual mode
  5            /usr/bin/uxterm                   20        manual mode
  6            /usr/bin/xterm                    20        manual mode
  7            /usr/local/bin/termite            60        manual mode

Press <enter> to keep the current choice[*], or type selection number:

但是,每次我运行更新时,此列表中的优先级都会自动修改,并且alacritty不再是默认程序(并从中删除auto mode):

$ sudo update-alternatives --config x-terminal-emulator
There are 7 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).

 ​Selection    Path                             Priority   Status
------------------------------------------------------------
* 0            /usr/local/bin/termite            60        auto mode
 ​1            /usr/bin/alacritty                50        manual mode
 ​2            /usr/bin/gnome-terminal.wrapper   40        manual mode
 ​3            /usr/bin/koi8rxterm               20        manual mode
 ​4            /usr/bin/lxterm                   30        manual mode
 ​5            /usr/bin/uxterm                   20        manual mode
 ​6            /usr/bin/xterm                    20        manual mode
 ​7            /usr/local/bin/termite            60        manual mode

Press <enter> to keep the current choice[*], or type selection number:

可以alacritty使用以下命令重置为默认终端仿真器:

$ sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/alacritty 70

直到更新运行,一切又回到原点。如何防止备选优先级被自动修改,alacritty永久设置为默认终端仿真器?

答案1

如何选择 Alacritty 作为默认终端仿真器。

要使用打开其默认终端的命令启动 Alacritty,需要将其定义为“终端”类型应用程序可用的替代方案:

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

(末尾的数字‘50’代表该条目的优先级)

或者尝试用/usr/local/bin/alacritty代替。

然后就可以使用以下命令将其定义为默认终端:

sudo update-alternatives --config x-terminal-emulator

最后,如果您想从可用替代方案中删除 alacritty:

sudo update-alternatives --remove "x-terminal-emulator" "/usr/bin/alacritty"

或者用 重试/usr/local/bin/alacritty

如果上述命令显示错误,我相信你可以dconf在默认的 ubuntu 桌面(gnome)上打开编辑器

dconf-editor

(首先会提示安装)

然后转到 org > gnome > 桌面 > 应用程序 > 终端,并将 gnome-terminal 更改为您选择的终端。

在此处输入图片描述

您可以在命令行中使用以下命令执行相同操作

gsettings set org.gnome.desktop.default-applications.terminal exec cmd_to_open_terminal_of_choice

此处以cmd_to_open_terminal_of_choice‘alacritty’表示,即没有其路径。

只要小心并确保您可以恢复默认设置(如果您过了一段时间忘记了它),该默认设置也在 dconf-editor 菜单中提供。

当您现在按下 Ctrl+Alt+T 时,将打开“alacritty”而不是“gnome-terminal”。

希望它能帮助你

答案2

正如您的第一张图片中显示的星号零和“自动模式”所示,链接组“x-terminal-emulator”位于自动模式

你想要的是将其设置为手动模式。这样,无论优先级如何,替代方案都会保留。您可以在输入 后选择“1”来实现这一点$ sudo update-alternatives --config x-terminal-emulator

这样,被选中的人alacritty就会留下来。

答案3

根据这里的答案判断https://stackoverflow.com/a/18647630下面的方法可行

gsettings set org.gnome.desktop.default-applications.terminal exec /usr/bin/alacritty

这可以在 gnome 中工作,但如果你有一个不同的 DE,你的里程可能会有所不同。

测试

nathans@skynet:~$ sudo gsettings set org.gnome.desktop.default-applications.terminal exec /usr/bin/terminator
[sudo] password for nathans: 
nathans@skynet:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi i965-va-driver intel-media-va-driver libaacs0 libaom0 libass9 libavcodec58 libavformat58 libavutil56 libbdplus0 libblas3 libbluray2
  libbs2b0 libchromaprint1 libcodec2-0.9 libdav1d4 libfftw3-double3 libflite1 libgme0 libgsm1 libgstreamer-plugins-bad1.0-0 libigdgmm11 liblilv-0-0 libllvm11 libmfx1 libmysofa1
  libnorm1 libopenmpt0 libpgm-5.3-0 libpostproc55 librabbitmq4 librubberband2 libserd-0-0 libshine3 libsnappy1v5 libsord-0-0 libsratom-0-0 libsrt1.4-gnutls libssh-gcrypt-4
  libswresample3 libswscale5 libudfread0 libva-drm2 libva-wayland2 libva-x11-2 libva2 libvidstab1.1 libx265-192 libxvidcore4 libzmq5 libzvbi-common libzvbi0 mesa-va-drivers
  ocl-icd-libopencl1 pocketsphinx-en-us va-driver-all
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  tzdata
1 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 standard security update
Need to get 296 kB of archives.
After this operation, 2,048 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 tzdata all 2021a-2ubuntu0.21.04 [296 kB]
Fetched 296 kB in 0s (1,730 kB/s)
Preconfiguring packages ...
(Reading database ... 178432 files and directories currently installed.)
Preparing to unpack .../tzdata_2021a-2ubuntu0.21.04_all.deb ...
Unpacking tzdata (2021a-2ubuntu0.21.04) over (2021a-1ubuntu1) ...
Setting up tzdata (2021a-2ubuntu0.21.04) ...

Current default time zone: 'Europe/London'
Local time is now:      Wed Oct  6 15:36:18 BST 2021.
Universal Time is now:  Wed Oct  6 14:36:18 UTC 2021.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

nathans@skynet:~$ sudo update-alternatives --config x-terminal-emulator 
There are 2 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).

  Selection    Path                             Priority   Status
------------------------------------------------------------
  0            /usr/bin/terminator               50        auto mode
  1            /usr/bin/gnome-terminal.wrapper   40        manual mode
* 2            /usr/bin/terminator               50        manual mode

更新答案以显示命令功能并在 ubuntu 21.04 上运行系统升级。

相关内容