mirror of
https://github.com/fscotto/infra.git
synced 2026-05-30 15:39:58 +00:00
Add fscotto/sudo-edit function to edit files as root via TRAMP
This commit is contained in:
@@ -225,3 +225,13 @@ Resume the latest saved session when available, otherwise create a new one."
|
||||
(unless (and sym (string-prefix-p "Test" sym))
|
||||
(user-error "No Go test at point"))
|
||||
sym))
|
||||
|
||||
(defun fscotto/sudo-edit (&optional arg)
|
||||
"Reopen current file as root via TRAMP.
|
||||
If ARG is provided (C-u), prompts for file path."
|
||||
(interactive "P")
|
||||
(if arg
|
||||
(find-file (concat "/sudo:root@localhost:" (read-file-name "File: ")))
|
||||
(if buffer-file-name
|
||||
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))
|
||||
(user-error "This buffer is not associated with a file"))))
|
||||
|
||||
Reference in New Issue
Block a user