5

Both of the following work to call a graphical/terminal eshell:

  • emacs -f eshell
  • emacs -nw -f eshell

Furthermore, this 2-step process also works:

  • `emacsclient -t -a '' /some/real/file/name
  • Metax eshell

BUT, this does not:

  • emacsclient -t -a '' -f eshell

and fails with this error after lots of normal startup messages:

Error: server did not start correctly
Error: Could not start the Emacs daemon

Note: On my system, I use alias edt="emacsclient -t -a '' to make sure that I always end up in a daemon-backed emacs session server

How can I, in one command,

  • launch emacsclient
  • launch and display a new eshell
  • OR display an existing eshell frame?

If I could also suppress the top 2 "Welcome to EShell" lines, that would also be useful

EDIT: I found this way of launching emacs with eval:

emacsclient -t -a '' --eval '(eshell)'

, but this always selects the pre-existing eshell. How would I then get a "new" one?

Alex Stragies
  • 403
  • 3
  • 14

1 Answers1

5

Surprisingly (at least to me), the -f flag means different things to emacs and emacsclient. To emacs, it means:

-f FUNCTION
--funcall=FUNCTION

Call Lisp function FUNCTION. If it is an interactive function (a command), it reads the arguments interactively just as if you had called the same function with a key sequence. Otherwise, it calls the function with no arguments.

Whereas for emacsclient:

-f SERVER-FILE
--server-file=SERVER-FILE

Specify a “server file” for connecting to an Emacs server via TCP.

So that's one problem solved. As for starting a new eshell session, from the help (C-h f eshell <return>):

(eshell &optional ARG)

Create an interactive Eshell buffer.
The buffer used for Eshell sessions is determined by the value of `eshell-buffer-name'. If there is already an Eshell session active in that buffer, Emacs will simply switch to it. Otherwise, a new session will begin. A numeric prefix arg (as in `C-u 42 M-x eshell RET') switches to the session with that number, creating it if necessary. A nonnumeric prefix arg means to create a new session. Returns the buffer selected (or created).

So we can get a fresh eshell process in an emacsclient with:

emacsclient -e '(eshell t)'
Tyler
  • 21,719
  • 1
  • 52
  • 92