[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ff3b696 338/348: counsel.el (counsel-find-file): Add new a
From: |
Oleh Krehel |
Subject: |
[elpa] master ff3b696 338/348: counsel.el (counsel-find-file): Add new action counsel-find-file-as-root |
Date: |
Sat, 8 Apr 2017 11:04:26 -0400 (EDT) |
branch: master
commit ff3b696b77cec4bc57470ecce8eef6d345b59251
Author: fabacino <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-find-file): Add new action counsel-find-file-as-root
Fixes #948
---
counsel.el | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/counsel.el b/counsel.el
index 9db9049..4084926 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1333,11 +1333,34 @@ done") "\n" t)))
:action (lambda (x)
(let ((default-directory (file-name-directory x)))
(counsel-find-file)))))
+
+(defcustom counsel-root-command "sudo"
+ "Command to gain root privileges."
+ :type 'string
+ :group 'ivy)
+
+(defun counsel-find-file-as-root (x)
+ "Find file with root privileges."
+ (let* ((host (file-remote-p x 'host))
+ (file-name (format "/%s:%s:%s"
+ counsel-root-command
+ (or host "")
+ (expand-file-name
+ (if host
+ (file-remote-p x 'localname)
+ x)))))
+ ;; If the current buffer visits the same file we are about to open,
+ ;; replace the current buffer with the new one.
+ (if (eq (current-buffer) (get-file-buffer x))
+ (find-alternate-file file-name)
+ (find-file file-name))))
+
(ivy-set-actions
'counsel-find-file
'(("j" find-file-other-window "other window")
("b" counsel-find-file-cd-bookmark-action "cd bookmark")
- ("x" counsel-find-file-extern "open externally")))
+ ("x" counsel-find-file-extern "open externally")
+ ("r" counsel-find-file-as-root "open as root")))
(defcustom counsel-find-file-at-point nil
"When non-nil, add file-at-point to the list of candidates."
- [elpa] master 2f70c56 287/348: Revert "Add missing parameter for ag", (continued)
- [elpa] master 2f70c56 287/348: Revert "Add missing parameter for ag", Oleh Krehel, 2017/04/08
- [elpa] master 950545b 304/348: counsel.el (counsel-linux-apps-list): Check if dir exists, Oleh Krehel, 2017/04/08
- [elpa] master 65979f6 291/348: Heed non-sort entries in ivy-sort-functions-alist, Oleh Krehel, 2017/04/08
- [elpa] master ce3c0ec 317/348: ivy.el (ivy-completing-read): Adjust :caller, Oleh Krehel, 2017/04/08
- [elpa] master d9d7592 315/348: ivy.el (ivy-completion-in-region): Remove :require-match, Oleh Krehel, 2017/04/08
- [elpa] master 4d72dc1 327/348: ivy.el: Change recursive restore order, Oleh Krehel, 2017/04/08
- [elpa] master d82dc2c 328/348: counsel.el (counsel-colors--best-contrast-color): Return same color on error, Oleh Krehel, 2017/04/08
- [elpa] master 3fbeaa5 333/348: Define ivy-help-file with defconst, Oleh Krehel, 2017/04/08
- [elpa] master fee9810 336/348: ivy.el (ivy-partial): Fix for :dynamic-collection, Oleh Krehel, 2017/04/08
- [elpa] master 5f04a70 322/348: ivy.el: Move ivy-recursive-last logic to ivy-call, Oleh Krehel, 2017/04/08
- [elpa] master ff3b696 338/348: counsel.el (counsel-find-file): Add new action counsel-find-file-as-root,
Oleh Krehel <=
- [elpa] master 8c9f6a3 340/348: swiper.el: Silence byte-compiler, Oleh Krehel, 2017/04/08
- [elpa] master a63a935 339/348: counsel.el (counsel--find-symbol): Fix typo, Oleh Krehel, 2017/04/08
- [elpa] master cba6888 344/348: Bump version to 0.9.0, Oleh Krehel, 2017/04/08
- [elpa] master 83b00ff 346/348: doc/Changelog.org: Fix links, Oleh Krehel, 2017/04/08