Skip to content

Instantly share code, notes, and snippets.

@JohnLunzer
Created June 28, 2016 19:53
Show Gist options
  • Save JohnLunzer/2a61627e5b1997742d76aadca34380a7 to your computer and use it in GitHub Desktop.
Save JohnLunzer/2a61627e5b1997742d76aadca34380a7 to your computer and use it in GitHub Desktop.
This snippet (which should go into your emacs config file) will update your tmux window name with the title of the buffer you're currently in which is usually the filename of the file you're editing.
(require 'deferred)
(defun rename-tmux-window()
(deferred:$
(deferred:process "tmux" "display-message" "-p" "'#I'")
(deferred:nextc it
(lambda (x)
(setq x (replace-regexp-in-string "\'" ""
(replace-regexp-in-string "\n\\'" "" x)))
(setq w
(replace-regexp-in-string "\*" ""
(car (mapcar
(function buffer-name)
(buffer-list)))))
(deferred:process "tmux" "rename-window" "-t" x w)))))
(add-hook 'change-major-mode-hook 'rename-tmux-window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment