I often want to have some kind of alias/substitution of 'bits' of a command.
ex: I want 'bkg' to translate to "2> /dev/null > /dev/null &" so that I can run applications in the background and not have their output spam the console like:
nautilus . bgk
>>>
nautilus . 2> /dev/null > /dev/null &
The closest thing I got to work so far is the following:
1) Create alias:
alias bkg="&> /dev/null > /dev/null &"
2) Before typing command, type alias and first expand it via ctrl+alt+e, then go back and type command.
bkg #press ctrl+alt+e
&> /dev/null > /dev/null & #has expanded. Now go back and type cmd:
nautilus &> /dev/null > /dev/null &
However, this is somewhat cumbersome.
[edit] ZSH seems to have global aliases. This is close to what I need. But from readings it appears that zsh is not fully compatible with bash scripts. It seems that switching to zsh only for global alising but breaking bash scripts might not be worth the effort. As such, looking for bash-native solution.
[edit]
As per @egmont's suggestion, something close to what I need is to define an alias:
alias quiet="&> /dev/null "
Then I can use it like:
quiet nautilus . &
However, two issues: "&" has to be at the end and tab-prediction doesn't work after 'quiet' is typed.