I have the following lines in my .bashrc:
# C-Z shortcut can be used to take a suspended job to fg
stty susp undef
bind '"\C-z":" fg >/dev/null 2>&1 \015"'
The purpose of this was to make the binding C-Z better suspend Vim (as it already does as default within Vim), and then use C-Z in the bash command line interface to get back to Vim immediately.
This seems to be working perfectly except for one thing:
me:~$ vim ~/.bashrc
[1]+ Stopped vim ~/.bashrc
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$
fg >/dev/null 2>&1 shows up every time. Is there any way to make this binding "silent" so that no output is shown at all? Many guides use zsh or fish to achieve this kind of behaviour, but I wish to stick to bash.
This should work for you:
stty susp undef
bind -x '"\C-z":"fg >/dev/null 2>&1"'
Keep in mind though that this might not be such a good idea, since it'll prevent you from suspending most other programs.
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