diff options
author | Franck Cuny <franck@fcuny.net> | 2021-10-17 18:15:37 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2021-10-17 18:15:37 -0700 |
commit | c86fb72bb100fb2cdc81ac5d30b71fe4d1ab7a1e (patch) | |
tree | 943cca3a166c53502c0eda14bee12935303a8969 /emacs | |
parent | aspell: word (diff) | |
download | emacs.d-c86fb72bb100fb2cdc81ac5d30b71fe4d1ab7a1e.tar.gz |
emacs: different prompt when on a remote host
Replace the prompt with `@<hostname>' when our current eshell path is on a remote host.
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/custom/fcuny-eshell.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/emacs/custom/fcuny-eshell.el b/emacs/custom/fcuny-eshell.el index 38d67da..c5523ce 100644 --- a/emacs/custom/fcuny-eshell.el +++ b/emacs/custom/fcuny-eshell.el @@ -76,10 +76,14 @@ length of PATH (sans directory slashes) down to MAX-LEN." (concat str (cl-reduce (lambda (a b) (concat a "/" b)) components)))) (defun fcuny/eshell-prompt () - (setq eshell-prompt-regexp "; ") + "Sets the prompt for eshell. If the current path is on a remote +host and starts with `ssh:', then we replace the prompt with +`@<hostname>' to indicate we're on a remote host." (concat - (concat (system-name) ":") - (fcuny/shorten-path (eshell/pwd)) + (let ((absolute-path (eshell/pwd))) + (if (string-match "/ssh:\\(.+\\):" absolute-path) + (replace-match (concat "@" (match-string 1 absolute-path) " ") nil nil absolute-path) + (fcuny/shorten-path absolute-path))) "; ")) (defun fcuny/eshell-here () |