In my bash terminal I have emacs set to run in XWindows. I prefer this to not freeze my terminal session so I run:
emacs filename &
Is there anyway to alias this? I have tried:
xemacs='emacs $1 &'
with no luck.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
alias "ec=emacsclient -cnqua ''"; ec my_file
I recommend running Emacs in daemon/server mode, where it opens a socket and remains in background waiting for a client to connect.
The most common client, distributed with Emacs and immediately available, is
An important feature of
emacsclient is that it can also start Emacs, in daemon mode, if said socket is not available.
To satisfy your requirements you need to start
emacsclient with a few non-default options but this can be achieved using a shell alias, e.g.,
$ alias "ec=emacsclient -cnqua ''" # the void string '' is IMPORTANT
-c, --create-frame Create a new frame instead of trying to use the current Emacs frame
the above ensures that Emacs opens a new frame and doesn't uses the terminal
-n, --no-wait Don't wait for the server to return
the above frees your terminal
-q, --quiet Don't display messages on success -u, --suppress-output Don't display return values from the server
the above silences as much as possible the client
-a EDITOR, --alternate-editor=EDITOR Editor to fallback to if the server is not running If EDITOR is the empty string, start Emacs in daemon mode and try connecting again
the above is the key, if an Emacs server/daemon is not running, the option
-a '' will start a new Emacs server.
You can kill the new frames using the window manager as you see fit but to kill the server you have to use the Emacs command