all repos — nixfiles @ d5f8c3b5d49cb5f95f8db903ae9ce718a542fc21

System and user configuration, managed by nix and home-manager

Emacs: Add nix generation info to title if built via nix
Alan Pearce alan@alanpearce.eu
Mon, 10 Jul 2017 14:10:45 +0200
commit

d5f8c3b5d49cb5f95f8db903ae9ce718a542fc21

parent

a0a7165e84f03b801f6bc3f3d530daedca26d955

1 files changed, 19 insertions(+), 1 deletions(-)

jump to
M emacs/.emacs.d/init.orgemacs/.emacs.d/init.org
@@ -293,7 +293,25 @@ (column-number-mode -1) (line-number-mode -1)
 (size-indication-mode t)
 
-(setq frame-title-format '("%f" (dired-directory dired-directory)))
+
+(require 'f)
+(if (f-ancestor-of? "/nix/store" invocation-directory)
+    (setq frame-title-format (list "Emacs (Nix Generation "
+                                   (cadr
+                                    (split-string (f-base
+                                                   (car
+                                                    (last (split-string
+                                                           (s-chomp (shell-command-to-string (concat "nix-store -q --roots " invocation-directory)))
+                                                           "\n"))))
+                                                  "-"))
+                                   " "
+                                   (s-left 6 (nth 3 (f-split invocation-directory)))
+                                   "..."
+                                   (s-right 6 (car (split-string (nth 3 (f-split invocation-directory)) "-")))
+                                   ")"
+                                   " —  %f"
+                                   '(dired-directory dired-directory)))
+    (setq frame-title-format '("Emacs — %f" (dired-directory dired-directory))))
 #+END_SRC
 
 ** Chrome