Single emacs, multiple files

May 25, 2009 01:36


If you'd like to be able to type "emacs file1.txt &" and later type "emacs file2.txt &" and have file1 open in the same emacs frame as file2, here's how. (This was pieced together from various sources on the web. If you've ever tried to figure out how to do something in emacs, you'll know that there's tons of documentation out there, but it assumes you know things you don't, or it's outdated.)

Edit your ~/.bash_profile line to contain the following lines:

alias emacs='emacsclient' export ALTERNATE_EDITOR=emacs
Now, edit your ~/.emacs file to contain the line:

(server-mode)
Either open a new terminal, or type source ~/.bash_profile.

Now, when you type emacs file2.txt & if there is an existing emacs running in "server mode," file2.txt will be opened in that emacs instance rather than spawning a new one.

This is similar behavior to the Mac OS X aquamacs file2.txt

linux, emacs, bash, computer

Previous post Next post
Up