How to re-evaluate shell environment and re-evaluate frame-title-format before opening each buffer in emacs How to re-evaluate shell environment and re-evaluate frame-title-format before opening each buffer in emacs shell shell

How to re-evaluate shell environment and re-evaluate frame-title-format before opening each buffer in emacs


Here is complete example of setting frame-title, currently it works only for git repos

(defun my-get-frame-title ()  "If inside a git repo return a string containing git repo, branch and file state elsereturn default frame title"  (let* ((file (buffer-file-name))         (git-directory (when file                          (locate-dominating-file (file-truename default-directory) ".git"))))    (if git-directory        (concat (file-name-nondirectory (buffer-file-name))                  " on " (vc-working-revision file)                 " in " (file-name-nondirectory (directory-file-name git-directory))                " current state is " (symbol-name (vc-state file)))      (concat invocation-name "@" system-name))))(setq-default  frame-title-format  '(:eval (my-get-frame-title)))

This set the frame title in git repos in the format <filename> on <branch> in <repo> current state is <state> otherwise it falls back to emacs' default frame title