I made a tiny patch to eshell (specifically em-dirs.el) which makes it return non-nil when you successfully 'cd' into a directory. This means you can do:
cd some-existing-directory && echo 'success'
Without the patch, it never gets to the echo.
I'm pretty much a lisp beginner, but this seems to work:
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 1aa2c34..26256a2 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -403,4 +403,5 @@ in the minibuffer:
(if eshell-list-files-after-cd
;; Let-bind eshell-last-command around this?
(eshell-plain-command "ls" (cdr args)))
- nil))))
+ nil))
+ ""))
(put 'eshell/cd 'eshell-no-numeric-conversions t)
It returns an empty string which satisfies the "&&" without printing any visible characters to the screen.
In practice, it looks like this:
~ $ cd /tmp
/tmp $ mkdir existing-dir
/tmp $ cd non-existant && echo "success"
No such directory found via CDPATH environment variable
/tmp $ cd existing-dir && echo "success"
success
/tmp/existing-dir $
Any feedback would be appreciated.
-Ted