在Emacs中打开一个su / sudo文件 [英] Open a file with su/sudo inside Emacs

查看:109
本文介绍了在Emacs中打开一个su / sudo文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想使用 su sudo 在现有的Emacs会话中打开一个文件,而不会下降到一个shell,并执行 sudoedit sudo emacs 。一种方式是

  Cx Cf / sudo :: / path / to / file 

但这需要一个昂贵的通过SSH往返。有更直接的方法吗?



@JBB是对的。我想要能够调用 su / sudo 保存以及打开。在保存时重新授权将是(但不是理想的)。我正在寻找的是 find-file save-buffer 的变体,可以通过 su / sudo

解决方案

关于Tramp的好处是,您只需要打开第一个文件即可支付SSH的往返次数。 Sudo然后缓存您的凭据,Emacs保存一个句柄,以便随后的sudo打开的文件占用更少的时间。



我没有找到额外的时间也可以减轻负担。这很快,IMO。


Suppose I want to open a file in an existing Emacs session using su or sudo, without dropping down to a shell and doing sudoedit or sudo emacs. One way to do this is

C-x C-f /sudo::/path/to/file

but this requires an expensive round-trip through SSH. Is there a more direct way?

[EDIT] @JBB is right. I want to be able to invoke su/sudo to save as well as open. It would be OK (but not ideal) to re-authorize when saving. What I'm looking for is variations of find-file and save-buffer that can be "piped" through su/sudo.

解决方案

The nice thing about Tramp is that you only pay for that round-trip to SSH when you open the first file. Sudo then caches your credentials, and Emacs saves a handle, so that subsequent sudo-opened files take much less time.

I haven't found the extra time it takes to save burdening, either. It's fast enough, IMO.

这篇关于在Emacs中打开一个su / sudo文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆