Gedit 作为 crontab 中的默认编辑器

J R*_*erg 5 editor gedit command-line cron default-programs

如何让 gedit 成为 crontab 的默认编辑器?

到目前为止,我已经尝试过:

sudo update-alternatives --install /usr/bin/gnome-text-editor gnome-text-editor /usr/bin/gedit 100
Run Code Online (Sandbox Code Playgroud)

sudo update-alternatives --install /usr/bin/editor editor /usr/bin/gedit 100
Run Code Online (Sandbox Code Playgroud)

到目前为止没有运气。(也许我只需要重新启动?)

Rav*_*ina 10

.profile使用您想要的编辑器打开文件:

gedit ~/.profile
Run Code Online (Sandbox Code Playgroud)

将此行添加到文件中并保存:

export EDITOR=gedit
Run Code Online (Sandbox Code Playgroud)

注销并重新登录。现在当你使用crontab -e它时会打开gedit.

请记住,它也将设置gedit为其他命令的默认编辑器,如果您希望它只影响crontab,那么您可以创建一个别名:

alias crontab='EDITOR=gedit crontab'
Run Code Online (Sandbox Code Playgroud)

  • 您可能想要使用 ubuntu/debian 程序 sensible-editor,它会根据您是否处于 X11 会话中来选择在 /etc/alternatives 中配置的图形/终端文本编辑器。 (2认同)