如何通过脚本在 Ubuntu 或 Lubuntu 中打开默认的 GUI 文本编辑器?

UAd*_*ter 10 gedit scripts lubuntu default-programs

我有一个使用 gedit 在 Ubuntu 中打开文本文件的脚本。该脚本在 Lubuntu 下不起作用。执行默认文本编辑器需要什么命令?

我想让脚本在 Ubuntu 和 Lubuntu 下可用。

小智 12

使用 xdg-open 它适用于大多数 linux 发行版。
例子:

xdg-open /filepath/file.txt
Run Code Online (Sandbox Code Playgroud)


Den*_*ker 5

您可能会使用/usr/bin/gnome-text-editor,因为它是使用替代系统设置的,并指向 gnome-ish 环境下的默认编辑器。不太确定它在 lubuntu/kubuntu 下是否真的有用,但你可以试试。


只是为了补充丹尼斯的回答,关于 Lubuntu 12.10,如果运行sudo update-alternatives --display gnome-text-editor,输出为:

gnome-text-editor - auto mode
  link currently points to /usr/bin/leafpad
/usr/bin/leafpad - priority 40
  slave gnome-text-editor.1.gz: /usr/share/man/man1/leafpad.1.gz
Current 'best' version is '/usr/bin/leafpad'.
Run Code Online (Sandbox Code Playgroud)

而且,正如丹尼斯所建议的那样,/usr/bin/gnome-text-editor确实在 Lubuntu 中打开了 Leafpad。