Emacs:编辑没有流浪汉的根文件
问题描述:
这是一个在非root运行emacs中打开根文件的方法:
Here's a way to open root file in a non-root run emacs:
erf () { SUDO_EDITOR="emacsclient -n -a emacs" sudoedit $@; } ;; erf = Emacs Root Foreground
它要求一个root密码,一旦你输入它,它打开一份文件在 / tmp
中。示例:
It asks a root password, and once You enter it it opens a copy of file in /tmp
. Example:
$ cd /etc/apt
$ erf sources.list
打开: sourcesXXiOSmYN.list
。所以我编辑的东西,并保存它与 Cx Cs
- 但它不保存:
opens: sourcesXXiOSmYN.list
. So I edit the thing, and save it with C-x C-s
-- but it's not saved:
$ sudoedit: sources.list unchanged
如何让它保存东西? (该功能将非常整齐)
How do I make it save the thing? (the feature will be very neat)
修改:
erf () { SUDO_EDITOR="emacsclient -a emacs" sudoedit $@; } ;; erf = Emacs Root Foreground
保存文件,或者 - 删除缓冲区或 C-x#
。
sovles it. Save a file and either -- kill the buffer or C-x #
. It works.
答
删除-n选项。 FWIW我使用,
Drop the -n option. FWIW I use,
alias E="SUDO_EDITOR=\"emacsclient -c -a emacs\" sudoedit"
在某处...