在编辑器列表中放置一个新的/图形编辑器

shi*_*ish 4 editors debian dpkg

我已经提出了一个查询之前,然后希望把leafpad编辑器列表中,但无法。

[$] sudo update-alternatives --set editor /usr/bin/leafpad                                                                       
update-alternatives: error: alternative /usr/bin/leafpad for editor not registered; not setting
Run Code Online (Sandbox Code Playgroud)

看一看,看到了这份清单——

??[$] sudo update-alternatives --config editor

There are 8 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/le          60        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/emacs24     0         manual mode
  4            /usr/bin/le          60        manual mode
  5            /usr/bin/ne          20        manual mode
  6            /usr/bin/nedit       40        manual mode
  7            /usr/bin/vim.basic   30        manual mode
  8            /usr/bin/vim.tiny    15        manual mode

Press <enter> to keep the current choice[*], or type selection number: ^C
Run Code Online (Sandbox Code Playgroud)

不知道为什么不能将 Leafpad 注册为有效的编辑器。如果您确实被转储到控制台并且由于某种原因无法使用图形编辑器,您可以随时运行 sudo update-alternatves --config editor 并修复相同的问题。这是一个错误还是需要在 Leafpad 或 update-alternatives/dpkg 端修复的东西?

giu*_*sti 6

语法通常是

update-alternatives --install link name path priority
Run Code Online (Sandbox Code Playgroud)

(加上一些我省略的可选参数)。

所以你可以这样做:

update-alternatives --install /usr/bin/editor editor /usr/bin/leafpad  0
Run Code Online (Sandbox Code Playgroud)

然后您可以重新运行相同的命令并选择leafpad成为您的编辑器。

在我的例子中,我给它的优先级为零。你可以选择不同的东西。它仅影响替代方案何时进入自动模式。不过,不要给 Leafpad 一个高优先级。您不希望图形编辑器成为默认选择,以防万一出现问题并且包会自动重新配置。