我正在使用 Ubuntu 10.04 Server 并尝试设置 sudoers 以尊重用户的 EDITOR 选择(在限制范围内)
在我的 sudoers 中,我有:
Defaults editor=/usr/bin/nano:/usr/bin/vim
Defaults env_reset
Run Code Online (Sandbox Code Playgroud)
在用户 .bashrc 中:
export EDITOR=/usr/bin/vim
Run Code Online (Sandbox Code Playgroud)
$EDITOR 设置:
$ echo $EDITOR
/usr/bin/vim
Run Code Online (Sandbox Code Playgroud)
根据man sudoers
这应该足以将 $EDITOR 设置为 vim:
editor A colon (':') separated list of editors allowed to be used with visudo.
visudo will choose the editor that matches the user's EDITOR environment
variable if possible, or the first editor in the list that exists and is
executable. The default is the path to …
Run Code Online (Sandbox Code Playgroud)