I tried to put this code in my Emacs init file:
(setq eshell-prompt-function (lambda ()
(concat "["
(user-real-login-name)
"@"
(system-name)
" "
(car (last (split-string (eshell/pwd) "/")))
"]$ ")))
It works nicely, but some errors appears:
- When I push UP key (to get last command executed), I get this message in minibuffer:
Not found
- When I push TAB key (to autocomplete a path), I get this message in minibuffer:
Invalid variable reference
I don't understand why this is happening. Could someone help me? Thanks!
Update
I entered debugger mode. When I press UP key (only UP key, not tab), debugger throws this error:
Debugger entered--Lisp error: (error "Not found")
signal(error ("Not found"))
error("Not found")
eshell-previous-matching-input("^\\[carlos@archlinux ~]\\$ " 1)
eshell-previous-matching-input-from-input(1)
funcall-interactively(eshell-previous-matching-input-from-input 1)
call-interactively(eshell-previous-matching-input-from-input nil nil)
command-execute(eshell-previous-matching-input-from-input)
Update 2
I set eshell-prompt-regexp to a regexp that matches my setup:
(setq eshell-prompt-regexp "\\[[[:alnum:]]+@[[:alnum:]]+[[:blank:]][[:print:]]+\\]\\$[[:blank:]].*")
Now, I can press UP and it works fine, but when I press TAB key to autocomplete a PATH, Emacs try to autocomplete with other 'thing'. For example, currently, I'm in a path that contains Programming directory. If I type cd Progr
and I press TAB key, Emacs try to autocomplete showing this message:
Click on a completion to select it. In this buffer, type RET to select the completion near point.
Possible completions are:
. 2to3
2to3-2.7 2to3-3.6
ControlPanel KateDJ
Magick++-config Magick-config
MagickCore-config MagickWand-config
NetworkManager Wand-config
WebKitWebDriver X
Xorg Xwayland
[ a2ping
and more. Why isn't emacs completing using directory? Lots of thanks to all comments and answers!