Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I customize the prompt of eshell? Specifically how can I prevent it from showing the full current path?

share|improve this question

migrated from Oct 30 '12 at 0:55

This question came from our site for professional and enthusiast programmers.

This is actually a valid question, given the lack of documentation in eshell. – pmr Oct 30 '12 at 0:36

1 Answer 1

up vote 1 down vote accepted

You can find a lot of possibilities to customize a prompt in the emacs wiki.

In the following example only three last directory names of the path will be shown, the directories in the beginning will be shortened to one letter:

(setq eshell-prompt-function
        (concat (getenv "USER") "@" (getenv "HOST") ":"
                ((lambda (p-lst)
                   (if (> (length p-lst) 3)
                        (mapconcat (lambda (elm) (substring elm 0 1))
                                   (butlast p-lst (- (length p-lst) 3))
                        (mapconcat (lambda (elm) elm)
                                   (last p-lst (- (length p-lst) 3))
                     (mapconcat (lambda (elm) elm)
                 (split-string (eshell/pwd) "/"))
                (if (= (user-uid) 0) " # " " $ "))))
share|improve this answer
I tried this: (setq eshell-prompt-function (lambda () "> ")) in order to get a clean '>' but this breaks my tab completion and 'C-c C-a' to go to beginning of command - is there a way not to break this and also have a simple prompt? – Palace Chan Oct 31 '12 at 23:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.