如何在Emacs中运行sudo命令?

前端之家收集整理的这篇文章主要介绍了如何在Emacs中运行sudo命令?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试为一些常用的sudo shell命令创建快捷键(例如,C-c的运行(shell命令“sudo /etc/init.d/apache2 restart”)).

我尝试使用如上所述的直接shell命令调用,但它只是输出以下内容到* Shell命令输出*缓冲区:

[sudo] password for Inaimathi:
Sorry,try again.
[sudo] password for Inaimathi:
Sorry,try again.
sudo: 3 incorrect password attempts

实际上并不要求输入密码.我不想使用sudo emacs启动Emacs,但是如果没有其他工作,我想这是一个选择.

理想的解决方案将是Emacs内的一个功能(而不是操作系统的诡计更改shell或sudo命令的行为). (sudo-shell-command“dostuff”)或(with-password-prompt(shell-command“sudo dostuff”)).

@H_502_9@ @H_404_10@@H_502_9@
怎么样:
(shell-command (concat "echo " (shell-quote-argument (read-passwd "Password? "))
                       " | sudo -S your_command_here"))
@H_502_9@ 原文链接:https://www.f2er.com/bash/386213.html

猜你在找的Bash相关文章