Skip to content

Instantly share code, notes, and snippets.

@hayamiz
Created September 23, 2008 06:19
Show Gist options
  • Save hayamiz/12227 to your computer and use it in GitHub Desktop.
Save hayamiz/12227 to your computer and use it in GitHub Desktop.
;;;
;;; Shell - '*shell*' will be renamed '*shell ($PWD)*'
;;;
(defun my-rename-buffer-with-pwd ()
(let ((cur-buffername (buffer-name))
(new-buffername (concat "*shell (" (pwd) ")*")))
(unless (equal cur-buffername new-buffername)
(rename-buffer new-buffername t))))
(defadvice comint-send-input (after rename-if-cd)
(if (eq major-mode 'shell-mode)
(my-rename-buffer-with-pwd)))
(ad-activate 'comint-send-input)
(add-hook 'shell-mode-hook
'(lambda ()
(my-rename-buffer-with-pwd)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment