I frequently execute from a shell (in my case Bash) commands that I want to fork immediately and whose output I want to ignore. So frequently in fact that I created a script (silent
) to do it:
#!/bin/bash
$@ &> /dev/null &
I can then run, e.g.
silent inkscape myfile.svg
and my terminal will not be polluted by the debug output of the process I just forked.
I have two questions:
Is there an "official" way of doing this?, i.e. something shorter but equivalent to &> /dev/null &
?
If not, is there a way I can make tab-completion work after my silent
command as if it weren't there ? To give an example, after I've typed silent inksc
, I'd like bash to auto-complete my command to silent inkscape
when I press [tab]
.
aside: probably want to exec "$@" &> /dev/null &
in your silent
script, to cause it to discard the sub-shell, and the quotes around "$@"
will keep spaces from getting in the way.
As for #2: complete -F _command silent
should do something like what you want. (I call my version of that script launch
and have complete -F launch
in my .bash_profile
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With