Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like a keyboard shortcut to work as so:

> e foo.txt

to expand as

> emacs foo.txt &

It's simple to use alias e=emacs, but how do I insert the & after the filename? I realize it may not be possible using just alias, so I'll accept any bash solution. If a shell script is needed please explain how it works.

share|improve this question
You should use emacsclient or gnuclient to open a file from command-line instead of opening a new emacs for each file: emacswiki.org/emacs/EmacsClient – andcoz Sep 23 '11 at 15:46
up vote 27 down vote accepted

Alias in bash can't have arguments, but you can use functions.

e() { emacs "$@" & }


e foo.txt

will do what you want.

share|improve this answer
This has a problem when I type e foo* in a directory with both foo.cpp and foo.h, only one of the files will open. – Hooked Sep 23 '11 at 18:50
@Hooked, then use "$@" instead of "$1" in the function. – AProgrammer Sep 23 '11 at 18:54
@AProgrammer that doesn't seem to work for wildcards. The syntax I'm using is: emacs $* & and an even better solution seems to be e() { command emacs $* & disown } – name Nov 19 '14 at 18:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.