0

I connect to an emacs server via emacsclient. Frequently the first thing I want open is a new buffer with an ansi-terminal in it.

Is there a way to launch emacsclient and to send the command "open a new buffer with an ansi-terminal"?

EDIT: Or better yet, is there a way to launch emacsclient with the command "if a buffer is already open with ansi-terminal, then go to that buffer; otherwise, launch ansi-terminal in a new window"?

1

This will launch emacs client with a new ansi-term:

emacsclient -c -a emacs -q --eval "(ansi-term \"/bin/bash\")"

If you have ansi-term already open why not just switch to that buffer?

If you really wanted to you can write a small lisp function to check if the buffer exists using (get-buffer name) otherwise open ansi-term. Then simply call that function in the eval statement above.

(if (get-buffer "*ansi-term*") 
   (switch-to-buffer "*ansi-term*")
  (ansi-term "/bin/bash"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.