Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use emacsclient on root files, using sudo and a single daemon

I always run emacs as daemon but when I want to make something alike

sudo emacsclient /etc/make.conf

I can't do it because root is using another emacs and I don't really want to run 2 daemons or wait usual emacs load for simple file.

I need some solution alike emacsclientsudo /etc/make.conf :) to edit system files with user emacs client.

like image 288
cnd Avatar asked Apr 17 '12 11:04

cnd


2 Answers

add to your ~/.profile:

alias E="SUDO_EDITOR=\"emacsclient\" sudo -e"

then

E /etc/hosts

You should be able to use sudoedit instead of sudo -e, but I couldn't find the former on my Mac.

like image 71
event_jr Avatar answered Sep 17 '22 21:09

event_jr


I'm not sure about it directly but here's a trick

emacsclient -e '(find-file "/sudo::/etc/passwd")'

Uses tramp and the sudo method to open /etc/passwd as root.

You can alias this and use it directly from your shell.

like image 26
Noufal Ibrahim Avatar answered Sep 20 '22 21:09

Noufal Ibrahim