From e716b27ffb37ebf0b75718950f366ae1171e4ad9 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 18 Dec 2021 19:46:58 -0800 Subject: 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. --- emacs/custom/fcuny-eshell.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'emacs') 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) " # " " $ "))) -- cgit 1.4.1