With the bind
command it is possible to define custom key bindings.
The next example bind an Alt + w to >/dev/null 2>&1
:
bind '"\ew"':"\" >/dev/null 2>&1\""
If you want to execute the line immediately add \C-m
(Enter) to it:
bind '"\ew"':"\" >/dev/null 2>&1\C-m\""