Created
May 9, 2013 14:12
-
-
Save dove-young/5547665 to your computer and use it in GitHub Desktop.
Rename shell-mode buffer to the destination host-name in SSH login Emacs natively support rename shell-mode buffer by appending numbers in each buffer. But it does not make any sense. I used to login to many different machines through Emacs shell-mode, so I'd like to have buffer name represent the host-name I am working on. Just like what many t…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq shell-buffer-name-list (list "*shell*") ) | |
(defun rename-buffer-in-ssh-login (cmd) | |
"Rename buffer to the destination hostname in ssh login" | |
(if (string-match "ssh .* [-_a-z0-9A-Z]+@[-_a-z0-9A-Z.]+[ ]*[^-_a-z0-9-A-Z.]*$" cmd) | |
(let (( host (nth 1 (split-string cmd "[@\n]" t) )) | |
) | |
(rename-buffer (concat "*" host)) | |
(add-to-list 'shell-buffer-name-list (concat "*" host)) | |
(message "%s" shell-buffer-name-list) | |
) | |
) | |
) | |
(add-hook 'comint-input-filter-functions 'rename-buffer-in-ssh-login) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment