Created
September 19, 2009 03:14
-
-
Save hinrik/189389 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(require 'xterm-title) | |
(xterm-title-mode 1) | |
(defun my-xterm-title () | |
"A hook function to update the xterm title. Attached to `post-command-hook'" | |
(let* ((fn (buffer-file-name)) | |
(fnd (file-name-directory fn)) | |
(dir-part (substring fnd 0 (- (length fnd) 1))) | |
(file-part (substring fn (1+ (length dir-part)) (length fn)))) | |
(cond ((buffer-file-name) (setq xterm-title-frame-title-format (list (getenv | |
"USERNAME") "@" (system-name) ": " file-part " (" dir-part ")"))) | |
(t (setq xterm-title-frame-title-format (list (getenv "USERNAME") "@" | |
(system-name) ": no file")))))) | |
(add-hook 'post-command-hook 'my-xterm-title) | |
;; set terminal title | |
(when (and (not window-system) | |
(string-match "^xterm" (getenv "TERM"))) | |
(require 'xterm-title) | |
(xterm-title-mode 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment