Reputation: 4941
How to determine inside a script - whether it has been executed from a eshell or from a normal shell (bash, etc.)?
Upvotes: 3
Views: 407
Reputation: 4941
Simply add (setenv "EMACS" "t") to ~/.emacs. So the behavior would be the same in all emacs shells.
Upvotes: 0
Reputation: 107739
Eshell doesn't set any particular environment variable. You can check $TERM
: it's set to dumb
under Eshell.
A more precise check would look at the parent process of the script
if [ -t 1 ] && [ "$TERM" = "dumb" ] && [ "$(ps -o comm= -p $PPID)" = "emacs" ]; then
echo "This looks a lot like eshell"
fi
Upvotes: 5
Reputation: 73246
I initially marked this as a duplicate of How do I tell a shell that it is running from within Emacs?, but I think the answer there is flawed or outdated, as although it explicitly mentions eshell
, it only seems to apply to shell
and term
and ansi-term
. eshell
must be the only kind of shell you can run in Emacs that doesn't set an obvious environment variable?
Upvotes: 1