summary refs log tree commit diff
path: root/emacs/custom
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--emacs/custom/my-eshell.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/emacs/custom/my-eshell.el b/emacs/custom/my-eshell.el
index db2d540..bf9a0b4 100644
--- a/emacs/custom/my-eshell.el
+++ b/emacs/custom/my-eshell.el
@@ -138,6 +138,35 @@ append to it, while separating multiple outputs with
   (add-hook 'eshell-pre-command-hook #'my/eshell-current-command-start nil t)
   (add-hook 'eshell-post-command-hook #'my/eshell-current-command-stop nil t))
 
+(defun my/short-pwd (path)
+  "Turn a PATH of the form /foo/bar/baz into /f/b/baz, like fish shell."
+  (let* ((home-path (replace-regexp-in-string (expand-file-name "~")
+                                          "~"
+                                          path))
+         (current-dir (split-string home-path "/"))
+         (cdir (last current-dir))
+         (head (butlast current-dir)))
+    (concat (mapconcat (lambda (s)
+                         (if (string= "" s) nil
+                           (substring s 0 1)))
+                       head
+                       "/")
+            (if head "/" nil)
+            (car cdir))))
+
+(defmacro with-face (str &rest properties)
+  "Set the PROPERTIES for the given STR."
+  `(propertize ,str 'face (list ,@properties)))
+
+(defun my/prompt ()
+  "EShell prompt displaying VC info and such."
+  (concat
+   (with-face (concat (my/short-pwd (eshell/pwd)) " ") :foreground  "#070707")
+   (if (= 0 (user-uid))
+       (with-face "#" :foreground "#f43841")
+     (with-face "λ" :foreground "#63c904"))
+   (with-face " " :foreground "#000000")))
+
 (global-set-key (kbd "C-c e h") 'my/eshell-here)
 (define-key eshell-mode-map (kbd "C-c e e") 'my/eshell-export)
 (define-key eshell-mode-map (kbd "C-o") 'my/eshell-open-file-at-point)
@@ -148,6 +177,8 @@ append to it, while separating multiple outputs with
 (customize-set-variable 'eshell-save-history-on-exit t)
 (customize-set-variable 'eshell-cd-on-directory t)
 (customize-set-variable 'eshell-prefer-lisp-functions nil)
+(customize-set-variable 'eshell-prompt-function 'my/prompt)
+(customize-set-variable 'eshell-highlight-prompt nil)
 (customize-set-variable 'eshell-where-to-jump 'begin)
 (customize-set-variable 'eshell-review-quick-commands nil)
 (customize-set-variable 'eshell-smart-space-goes-to-end t)