将emacs -nw设置为默认编辑器
在编辑像sudoers
这样的文件时,我想使用emacs而不是nano。 所以我运行了这个命令
sudo update-alternatives --config editor
我选择了emacs。 唯一的问题是我喜欢没有窗口模式的emacs(-nw标志)而且我把emacs别名为emacs='emacs -nw'
这样我就可以在正常使用中不使用窗口模式,但我不知道如何让我的默认编辑器处于无窗口模式。
换句话说,我需要获取命令sudo visudo
和类似的命令,打开编辑器以使用emacs -nw
打开文件。 我怎样才能做到这一点? 我在Ubuntu 12.04上。
创建一个使用-nw标志启动emacs的脚本,例如/ usr / local / bin / emacs-nw。
#!/bin/sh emacs -nw "$@"
使用update-alternatives –install安装它。
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/emacs-nw 2
将编辑器配置为新脚本。
sudo update-alternatives --set editor /usr/local/bin/emacs-nw
将以下内容添加到~/.bashrc
文件中(如果它不是Bash,则添加到shell的配置文件中)。
export EDITOR="emacs -nw"
这应该设置(并导出)一个env变量,在非图形模式下将默认编辑器设置为Emacs。
我在~/.bashrc
以下设置
export EDITOR="emacsclient -t -a=\"\""
这将首先尝试连接emacs守护程序服务器(如果它已经启动),否则首先启动守护程序服务器然后再次连接。
同样,我在~/.gitconfig
以下设置
[core] editor = emacsclient -t -a=\\\"\\\"
- 从键盘快捷方式启动应用程序与终端之间的区别?
- 各种版本的emacs之间有什么区别?
- Ubuntu中的文本编辑器之间的比较:Vim与Emacs vs. Nano
- 如何从unity启动器重新使用现有的emacs窗口运行emacsclient
- 非sudo的Gedit错误 – 未定义的符号:cairo_surface_set_device_scale(未定义的符号:cairo_surface_set_device_scale)
- 当某个程序打开时,如何在Cinnamon中禁用Alt-Tab应用程序切换?
- 在Ubuntu 16.04中更改了语法突出显示
- 无法从ppa:cassou / emacs安装Emacs 24
- 旧键盘上的超级键的替代品