A good way to get back to the command prompt discarding STDOUT and STDERR

bashcommand lineredirectionrouting

I often launch applications from the cli via e.g. command & to immediately get back to the prompt back.
The downside of this is, that I still get STDOUT and STDERR.

So I use command &> /dev/null to discard those outputs.

This can get quite a chore, when having to write this often during a day.

So my question is, is there a better (read shorter) way to discard of STDOUT and STDERR when not needed?

What could be done? Maybe write a wrapper script to launch applications?
What would be an elegant way to do this?

Best Answer

You can define a function (e.g., in your .alias, .bashrc file)

launch () 
{ 
    "$@" >&/dev/null &
}

This can then be used as

launch command

For example

launch xemacs ./myfile.txt
Related Question