Emacs: Re-add find-file-as-root advice for counsel
1 file changed, 5 insertions(+), 0 deletions(-)
jump to
M tag-emacs/emacs.d/init.org → tag-emacs/emacs.d/init.org
@@ -1246,6 +1246,11 @@ ("C-c M-x" . execute-extended-command) ("C-x C-f" . counsel-find-file) ("C-x b" . counsel-switch-to-projectile-buffer)) :config (progn + (defadvice counsel-find-file (after find-file-sudo activate) + "Find file as root if necessary." + (unless (and buffer-file-name + (file-writable-p buffer-file-name)) + (find-alternate-file (concat "/sudo::" buffer-file-name)))) (defun counsel-switch-to-projectile-buffer (arg) "Forward to `projectile-switch-to-buffer'." (interactive "P")