I often have need of a shell while using Emacs. Recently, I have been trying to switch over from shell
to eshell
, so that I will be able to use the same commands regardless of platform.
One of the first things I would like to do is customize my prompt to match my bash
prompt. To do this, I am customizing eshell-prompt-function
. The only thing I am still missing is the current command count and the last return code. I can do this in bash
by setting PS1
to e.g. \!
and $?
respectively. I have already tried (eshell/echo "$?")
for the latter, but it doesn't work (though it works if I execute the command manually in eshell).
Edit:
An example of what part of my current bash
prompt looks like is [~][501:0]
, where 501
is the current command number (so if I type a command and hit Enter
it will show 502
), and the 0
is the return code.