summary refs log tree commit diff
path: root/emacs/custom
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-12-18 19:46:58 -0800
committerFranck Cuny <franck@fcuny.net>2021-12-18 19:46:58 -0800
commite716b27ffb37ebf0b75718950f366ae1171e4ad9 (patch)
treea18a24248b5ec3d069568dc4fb05bf9da0874c44 /emacs/custom
parentaspell: more words (diff)
downloademacs.d-e716b27ffb37ebf0b75718950f366ae1171e4ad9.tar.gz
eshell: add the host's name in the prompt
The name of the host is added at the beginning of the prompt, and a
background color is set to make it obvious.
Diffstat (limited to 'emacs/custom')
-rw-r--r--emacs/custom/fcuny-eshell.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/emacs/custom/fcuny-eshell.el b/emacs/custom/fcuny-eshell.el
index f4b0737..6bcef86 100644
--- a/emacs/custom/fcuny-eshell.el
+++ b/emacs/custom/fcuny-eshell.el
@@ -75,6 +75,7 @@
 parent directories with their initial characters to try to get the character
 length of PATH (sans directory slashes) down to MAX-LEN."
   (let* ((components (split-string (abbreviate-file-name path) "/"))
+         (host (propertize (system-name) 'face `(:background "#4ba9aa")))
          (max-len (or max-len 30))
          (len (+ (1- (length components))
                  (cl-reduce '+ components :key 'length)))
@@ -93,7 +94,7 @@ length of PATH (sans directory slashes) down to MAX-LEN."
                                  (string (elt (car components) 0) ?/)))))
             len (- len (1- (length (car components))))
             components (cdr components)))
-    (concat str (cl-reduce (lambda (a b) (concat a "/" b)) components))))
+    (concat host " " str (cl-reduce (lambda (a b) (concat a "/" b)) components))))
 
 (defun fcuny/eshell-prompt ()
   "Sets the prompt for eshell. If the current path is on a remote
@@ -102,7 +103,7 @@ host and starts with `ssh:', then we replace the prompt with
   (concat
    (let ((absolute-path (eshell/pwd)))
      (if (string-match "/ssh:\\(.+\\):" absolute-path)
-         (replace-match (concat "@" (match-string 1 absolute-path) " ")  nil nil absolute-path)
+         (replace-match (propertize (concat "@" (match-string 1 absolute-path) " ") 'face `(:background "#4ba9aa"))  nil nil absolute-path)
        (fcuny/shorten-path absolute-path)))
    (if (= (user-uid) 0) " # " " $ ")))