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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must also set eshell-prompt-regexp to match what eshell-prompt-function returns or you'll have problems like Palace Chan in the comment above this.

share|improve this answer
This is really a comment and not an answer to the original question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead? – DavidPostill Jun 10 at 20:32

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.