Skip to content

Instantly share code, notes, and snippets.

@hinrik
Created September 19, 2009 03:14
Show Gist options
  • Save hinrik/189389 to your computer and use it in GitHub Desktop.
Save hinrik/189389 to your computer and use it in GitHub Desktop.
(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