How to open a file in an existing emacs process from command line?
M-x server-start
inside the Emacs session, then use emacsclient -n file1 file2 ...
to add files to the existing Emacs. There are additional options you might want to use, e.g. -c
to open the files in a new window (frame).
Put (server-start)
in your .emacs
file.
Add this to ~/.bashrc
alias myedit='emacsclient --alternate-editor="" --no-wait $*' #quotes intentionaly left blank
then use myedit
as your editor. You will have to use the -c
option to bring up a window.
So you may do this:
myedit -c a-file
run-script #that uses myedit
or
run-script #that uses myedit
myedit -c