summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
authorAlan Pearce2017-07-10 14:10:45 +0200
committerAlan Pearce2017-07-10 14:10:45 +0200
commitd5f8c3b5d49cb5f95f8db903ae9ce718a542fc21 (patch)
treecb411098f35d7172b895b471432bf07fc5845068 /emacs
parenta0a7165e84f03b801f6bc3f3d530daedca26d955 (diff)
downloadnixfiles-d5f8c3b5d49cb5f95f8db903ae9ce718a542fc21.tar.lz
nixfiles-d5f8c3b5d49cb5f95f8db903ae9ce718a542fc21.tar.zst
nixfiles-d5f8c3b5d49cb5f95f8db903ae9ce718a542fc21.zip
Emacs: Add nix generation info to title if built via nix
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init.org20
1 files changed, 19 insertions, 1 deletions
diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index 99d5899c..59bf5d4d 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -293,7 +293,25 @@ correct, at least for Liberation Mono.
 (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