EddyTheB
EddyTheB

Reputation: 3200

Implicitly launch detached program (&) from terminal

I feel sure this will end up as a duplicate, but I don't know how to word it so that I can search for it...

I like to do my programming in emacs, which I launch from the terminal. When I use my mac I use aquamacs and the command

aquamacs Program.py

will launch aquamacs in a separate window ready to edit Program.py. When I work on my linux machine however to get the same result I must type

emacs Program.py &

And I'm always forgetting the "&". So 70% of the time I end up closing the emacs window, and relaunching again with the "&". Now I understand why that "&" is there, but is there a way to set up my system so that the command

emacs Program.py

always launches as a detached process? The only time I might not want that behavior is if I was SSHing in over a slow connection, in which case I usually use "-nw" anyway.

Upvotes: 0

Views: 365

Answers (2)

aap
aap

Reputation: 408

For the specific case of emacs, I use a shell script, which is more complicated than this but for your purposes boils down to

#!/bin/csh -f
/bin/emacs $*:q &

Put it in a directory which is earlier in your $path than where the "real" emacs is, and replace /bin/emacs with the real path to emacs on your system.

Upvotes: 0

John Kugelman
John Kugelman

Reputation: 361585

You can click on the terminal and press Ctrl-Z to move an already running foreground process to the background.

Alternatively you could add this function to your ~/.bashrc:

emacs() {
    command emacs "$@" &
}

Upvotes: 3

Related Questions