[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding simpler better sudo for Emacs
From: |
Jean Louis |
Subject: |
Re: Finding simpler better sudo for Emacs |
Date: |
Tue, 30 Mar 2021 13:43:18 +0300 |
User-agent: |
Mutt/2.0.6 (2021-03-06) |
* Michael Albinus <michael.albinus@gmx.de> [2021-03-30 13:35]:
> Jean Louis <bugs@gnu.support> writes:
>
> Hi Jean,
>
> > (defun sudo (&rest arguments)
> > "Executes list ARGUMENTS with system command `sudo'."
> > (let ((default-directory
> > (concat "/sudo::" (file-local-name default-directory))))
> > (shell-command-to-string (string-join arguments " "))))
> >
> > (sudo "ls") → " 0install-ea1f1e-download
> > 847cf980479cf1dd15482464efa8620ca98c1c93c5a3ac1e2a1dd24918b9cd46.html
> > adb.1001.log" ;; are files from my tmp
> >
> > but then if I change to dired buffer ~/tmp and do: M-: -- (sudo "ls")
> > I get following error:
> >
> > "sh: cd: /root/tmp/: No such file or directory
>
> OK, so let's do
>
(defun sudo (&rest arguments)
"Executes list ARGUMENTS with system command `sudo'."
(let ((default-directory
(concat "/sudo::" (file-local-name (expand-file-name
default-directory)))))
(shell-command-to-string (string-join arguments " "))))
(sudo "ls") → " 0install-ea1f1e-download
847cf980479cf1dd15482464efa8620ca98c1c93c5a3ac1e2a1dd24918b9cd46.html
adb.1001.log
..."
(sudo "ls") → " 0install-ea1f1e-download
847cf980479cf1dd15482464efa8620ca98c1c93c5a3ac1e2a1dd24918b9cd46.html
adb.1001.log
..."
That one works well. I will keep it.
On the other hand, now I have got concern for this command:
(defun sudo (arguments)
"Executes list ARGUMENTS with system command `sudo'."
(let* ((command (format "sudo su -c -- root -c \"%s\"" (string-join (list
arguments))))
(return (shell-command-to-string command)))
return))
As I would not like, definitely I would not like executing my sudo
commands on remote servers which I use so often with the above sudo
command.
So I would like to make sure I am on the local file system, as if I am
on /sudo:: file system or /ssh: or similar, that is not something I
would like. I have multiple notebooks which I access, imagine I change
default directory to some remote one and I am not visible in the
buffer of Dired. This happens sometimes. Then I wish to execute fan
control, but it would run on remote computer.
How to check if default directory is on local file system?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
- Control of fan-speed on Lenovo Thinkpads, Jean Louis, 2021/03/29
- Re: Control of fan-speed on Lenovo Thinkpads, Michael Albinus, 2021/03/30
- Re: Control of fan-speed on Lenovo Thinkpads, Jean Louis, 2021/03/30
- Re: Control of fan-speed on Lenovo Thinkpads, Jean Louis, 2021/03/30
- Re: Control of fan-speed on Lenovo Thinkpads, Michael Albinus, 2021/03/30
- Finding simpler better sudo for Emacs, Jean Louis, 2021/03/30
- Re: Finding simpler better sudo for Emacs, Michael Albinus, 2021/03/30
- Re: Finding simpler better sudo for Emacs,
Jean Louis <=
- Re: Finding simpler better sudo for Emacs, Michael Albinus, 2021/03/30
- Re: Finding simpler better sudo for Emacs, Jean Louis, 2021/03/30
- Re: Finding simpler better sudo for Emacs, Michael Albinus, 2021/03/30
- Re: Finding simpler better sudo for Emacs, Jean Louis, 2021/03/30
Re: Control of fan-speed on Lenovo Thinkpads, Stefan Monnier, 2021/03/30
- Re: Control of fan-speed on Lenovo Thinkpads, Jean Louis, 2021/03/30
- Re: Control of fan-speed on Lenovo Thinkpads, Stefan Monnier, 2021/03/30
- Re: Control of fan-speed on Lenovo Thinkpads, Jean Louis, 2021/03/31
- Re: Control of fan-speed on Lenovo Thinkpads, Stefan Monnier, 2021/03/31
- Re: Control of fan-speed on Lenovo Thinkpads, Jean Louis, 2021/03/31