Skip to content

Instantly share code, notes, and snippets.

@itorres
Created July 13, 2016 14:33
Show Gist options
  • Save itorres/b3054204614b96c08e8d86bab468486b to your computer and use it in GitHub Desktop.
Save itorres/b3054204614b96c08e8d86bab468486b to your computer and use it in GitHub Desktop.
Emacs function to rename shell buffer based on path and tramp host (if this is a tramp buffer)
(defun my-rename-shell-buffer ()
"Rename the current shell buffer name."
(interactive)
(let ((candidate-name
(concat
(if (string-prefix-p "/ssh:" default-directory)
(concat tramp-current-host ":")
"")
(file-name-base (directory-file-name default-directory)))))
(rename-buffer (format "*shell* <%s>" candidate-name))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment