Bash - Advanced Shortcuts

This is a list of my personal “hard-to-remember” bash shortcuts that I don’t know by heart (but should), even after years of using bash.

One I sometimes try hard to remember is

This one is similar to Tab-Tab, but writes the completions on the command line, so you can edit them. Great if you want to run on all files matching the completion, except for one.

Another arcane one that could potentially be useful is

It is unfortunately bound by the window managers to switch the active window. However, combinations with Alt (or Meta, as bash’s man page would say) can be replaced by sequencing with Escape instead. Use the sequence Esc, Tab, i.e. first Escape, then Tab. As with regular Tab completion, if there is more than one possibility you need to do it twice. In the sequence version that is Esc, Tab, Esc, Tab.

There is also a host of similar completion commands for special completions. They come in two versions: The symbol together with Alt (e.g. Alt+/) to insert the possible completions or after Ctrl-x (e.g. Ctrl-x, /) to just show them.

There are many more shortcuts, but for many I feel I won’t need them often enough to ever memorize them, e.g. (un)capitalization.

  1. There is even a more powerful (and complex) command for picking arguments from the previous command line: Alt+Ctrl+y. By itself, it inserts the first argument (excluding the command, i.e. it picks the second word). However, it can be prefixed by, e.g., Alt+5 to pick the fifth argument (i.e. the sixth word) from the previous command line. It is even be possible to use negative numbers to count the arguments from the back by starting with Alt+- (then release Alt and enter a digit).