Skip to content

Instantly share code, notes, and snippets.

@hyOzd
Created August 25, 2016 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyOzd/dfd6b201cd43fabcb40018a05cc73f2a to your computer and use it in GitHub Desktop.
Save hyOzd/dfd6b201cd43fabcb40018a05cc73f2a to your computer and use it in GitHub Desktop.
emacs open this file as sudo
;; open this file in sudo
(defun sudo-this ()
"Open currently visited file as sudo!"
(interactive)
(if buffer-file-name
(let ((to-close (current-buffer)))
(find-file (s-concat "/sudo:root@localhost:" buffer-file-name))
(kill-buffer to-close))
(message "No file!")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment