Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I run a program from terminal like so:

 $ program file  

For example

 $ gedit myfile.txt

I cannot think of a time when I would not prefer to use '&' so that I can free up my terminal for use while the program is running.

Does anyone know where or how I might set this '&' as an argument for such situations?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can create a shell function:

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

or

function gedit() { command gedit "$@" & }

The function keyword is, in theory at least, optional. It may be necessary if the function name is already defined as an alias; see this answer for details.

The command build-in invokes its argument as a command, bypassing any shell function of the same name.

Add the definition to your $HOME/.bashrc so it will be set up when you start a new shell.

share|improve this answer

Your Answer

 
discard

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.