In other words, can I start emacs once, and whenever I type emacs whatever in terminal, have it open as a buffer in my existing emacs instance?
[rant]This yet another of those features that is a no-brainer and enabled by default on many other editors, but proves to be quite difficult in Emacs.[/rant]
Anyway, here's how I have done it. First, as jwernerny mentioned, EmacsClient does the trick. All you have to do to edit foo.txt is
This command will try to connect to a running Emacs server. If there is no server, it will start one. It will then connect to the server and instruct it to open the specified file.
The server runs as a daemon (background process). If you run
Here's what I have added to my .bashrc:
and the contents of
For an editor command that waits until you're finished with the file (good for Git commits etc), remove the