What does the “magic space” do?
Given the following:
$ find -wholename '*/path/to/file' -print -quit $ man rm $ rm -fv !-2:2
In the last line, feedback would be appreciated to see if we are indeed going to delete the second argument of two commands back. If you set Bash’ so-called “magic space”, history expansion will take place right away after typing a space after
$ rm -fv '*/path/to/file'
How to enable the magic space?
Put the following in your
$if Bash Space: magic-space $endif
Start a new session, or use
bind -f ~/.inputrc to put the changes in effect immediately.
Other ways to achieve the same
You could also enable
shopt -s histverify, which will perform the history expansion and give you another opportunity to modify the command before executing it. This requires you to press enter, though.