Script for one-Emacs-frame editing of files
September 2, 2010
This script allows you to edit files in one, and only one, Emacs frame (window). Save this as an executable somewhere in your path (i.e. as ~/bin/e).
#!/bin/bash export GDK_NATIVE_WINDOWS=1 if [ "$(pgrep emacs)" ] then exec emacsclient -n "$@" 2>/dev/null else exec emacs "$@" & disown fi
In addition, you have to call (server-start) in your .emacs file.
You can call this script as an executable (don’t forget to run chmod 755 ~/bin/e) from anywhere you like (e.g. e ~/myfile.txt), and it will open the file for editing in a new or existing Emacs frame. If you call this in a terminal, it won’t wait for the Emacs server, but will immediately return to your terminal session.