New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel.el (counsel-find-file): Add new action counsel-find-file-as-root #948

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@fabacino
Contributor

fabacino commented Apr 7, 2017

Adds a new action to counsel-find-file to open a file with root privileges.

@dieggsy

This comment has been minimized.

Contributor

dieggsy commented Apr 7, 2017

It would be nice if files that required root access prompted for it automatically... is this possible?

@abo-abo abo-abo closed this in ff3b696 Apr 7, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Apr 7, 2017

Thanks. I wonder if counsel-root-command is really necessary. Do other systems have an alternative to sudo?

@fabacino

This comment has been minimized.

Contributor

fabacino commented Apr 10, 2017

@therockmandolinist I would suggest using a wrapper around counsel-find-file-as-root and calling that function explicitly when you need root privileges, maybe something like this:

(defun my/open-as-root ()
  (interactive)
  (when (and buffer-read-only
             buffer-file-name)
    (counsel-find-file-as-root buffer-file-name)))
(global-set-key (kbd "<f12>") 'my/open-as-root)

I would advise against automatically enabling root access to every file you open, but if you really want to do this, you could use pretty much the same function as an :after advice for find-file.

@fabacino

This comment has been minimized.

Contributor

fabacino commented Apr 10, 2017

@abo-abo I thought some users might prefer su over sudo, that's why I didn't hard code it.

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Apr 10, 2017

But does su work the same way? I thought su was only usable without an argument.

@fabacino

This comment has been minimized.

Contributor

fabacino commented Apr 10, 2017

su works as well, /su::/path/to/file expands to /su:root@localhost:/path/to/file.

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Apr 10, 2017

I see, so it's Emacs magic. Thanks.

@fabacino fabacino deleted the fabacino:feature/find-file-as-root branch Apr 12, 2017

DamienCassou added a commit to DamienCassou/swiper that referenced this pull request Dec 25, 2017

counsel.el (counsel-bookmark): Add 2 actions
Port 2 actions from counsel-find-file to counsel-bookmark: namely
counsel-find-file-extern and counsel-find-file-as-root.

Closes abo-abo#948

abo-abo added a commit that referenced this pull request Dec 25, 2017

counsel.el (counsel-bookmark): Add 2 actions
Port 2 actions from counsel-find-file to counsel-bookmark: namely
counsel-find-file-extern and counsel-find-file-as-root.

Closes #948
Fixes #1385
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment