From 802994ccc9651aea7513401215ebd2c758f20fc2 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 10 Nov 2016 11:26:35 +0100 Subject: [PATCH] Add now post on open-this-file-as-other-user Emacs function --- ...-11-10-edit-file-as-other-user-in-emacs.md | 27 +++++++++++++++++++ css/style.sass | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 _posts/2016-11-10-edit-file-as-other-user-in-emacs.md diff --git a/_posts/2016-11-10-edit-file-as-other-user-in-emacs.md b/_posts/2016-11-10-edit-file-as-other-user-in-emacs.md new file mode 100644 index 0000000..c2997d8 --- /dev/null +++ b/_posts/2016-11-10-edit-file-as-other-user-in-emacs.md @@ -0,0 +1,27 @@ +--- +layout: post +title: "Edit file as another user in Emacs" +date: 2016-11-10 08:57:12 +tags: [development, emacs] +published: true +author: + name: Gergely Polonkai + email: gergely@polonkai.eu +--- + +I have recently found +[this article](http://emacsredux.com/blog/2013/04/21/edit-files-as-root/) by +Bozhidar Batsov on opening the current file as root. I barely use +[tramp](https://www.gnu.org/software/tramp/) for sudo access, but when I do, +I almost never use root as the target user. So I decided to fix it for my +needs. + +{% gist gergelypolonkai/192c83aa0556d5cdaf4018f57b75a84b %} + +If the user is not specified, the default is still root. Also, if the +current buffer is not visiting a file, I prompt for a filename. As I’m not +an `ido` user, I didn’t bother calling +`ido-read-file-name`; [`helm`](https://github.com/emacs-helm/helm/wiki) +overrides `read-file-name` for me anyway. + +Unlike Bozhidar, I barely use this feature, so I didn’t bind this to a key. diff --git a/css/style.sass b/css/style.sass index 9da8cb8..0e717ff 100644 --- a/css/style.sass +++ b/css/style.sass @@ -51,6 +51,9 @@ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 a color: $link-color + code + text-decoration: underline + #main-container background-color: $content-background