summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.org5
1 files changed, 5 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index 008b5b16..dd19554a 100644
--- a/tag-emacs/emacs.d/init.org
+++ b/tag-emacs/emacs.d/init.org
@@ -1246,6 +1246,11 @@ replace helm and ido.
            ("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")