diff options
| author | Davide Masserut | 2023-08-29 22:33:48 +0200 |
|---|---|---|
| committer | Jim Porter | 2023-09-02 15:40:04 -0700 |
| commit | 3d08d0dd80a02419f8301b63bb5663710f4f8ee2 (patch) | |
| tree | ad7a0223d01f0c183926c52c6fe27bd2bff1f6fd /lisp/eshell | |
| parent | 6ae2b74ed20f7c96384ed67981405212d7e2bea2 (diff) | |
| download | emacs-3d08d0dd80a02419f8301b63bb5663710f4f8ee2.tar.gz emacs-3d08d0dd80a02419f8301b63bb5663710f4f8ee2.zip | |
Display the exit code if the last command failed in Eshell
* lisp/eshell/esh-io.el (eshell-last-command-status): Make
buffer-local.
* lisp/eshell/em-prompt.el (eshell-prompt-function): Insert the exit
code if last command failed.
* test/lisp/eshell/em-prompt-tests.el (em-prompt-test/after-failure):
New test.
(em-prompt-test/next-previous-prompt-1)
(em-prompt-test/forward-backward-matching-input-1): Add a failing
command to tests.
* doc/misc/eshell.texi (Invocation): Document change.
* etc/NEWS: Announce change (bug#65604).
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/em-prompt.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/esh-io.el | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index a5abb75bccc..15b849a4d37 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el | |||
| @@ -50,6 +50,8 @@ as is common with most shells." | |||
| 50 | (defcustom eshell-prompt-function | 50 | (defcustom eshell-prompt-function |
| 51 | (lambda () | 51 | (lambda () |
| 52 | (concat (abbreviate-file-name (eshell/pwd)) | 52 | (concat (abbreviate-file-name (eshell/pwd)) |
| 53 | (unless (eshell-exit-success-p) | ||
| 54 | (format " [%d]" eshell-last-command-status)) | ||
| 53 | (if (= (file-user-uid) 0) " # " " $ "))) | 55 | (if (= (file-user-uid) 0) " # " " $ "))) |
| 54 | "A function that returns the Eshell prompt string." | 56 | "A function that returns the Eshell prompt string." |
| 55 | :type 'function | 57 | :type 'function |
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index c07f871dd37..cd0cee6e21d 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el | |||
| @@ -170,7 +170,7 @@ describing the mode, e.g. for using with `eshell-get-target'.") | |||
| 170 | 170 | ||
| 171 | (defvar eshell-current-handles nil) | 171 | (defvar eshell-current-handles nil) |
| 172 | 172 | ||
| 173 | (defvar eshell-last-command-status 0 | 173 | (defvar-local eshell-last-command-status 0 |
| 174 | "The exit code from the last command. 0 if successful.") | 174 | "The exit code from the last command. 0 if successful.") |
| 175 | 175 | ||
| 176 | (defvar eshell-last-command-result nil | 176 | (defvar eshell-last-command-result nil |