How to you reverse the direction of alt-period in Bash

bashcommand historykeyboard shortcutsshellterminal

In Bash, you can press Alt. to insert the last argument of the previous command. If you press it multiple times, it cycles through the last arguments of all of the commands in your history. However, sometimes I press it too many times, and I want to reverse the direction of the cycling, hence go forwards. Is this possible?

(i.e. if you reverse-i-search with Ctrlr, you can change directions with Ctrls. What is the analogue for Alt.?)

Best Answer

If you supply a negative argument to Alt-., it reverses direction. The easiest way to do that (with standard keybindings) is Alt-- (equivalent to an argument of -1).

So, after one or more Alt-. keypresses, pressing Alt-- will cause the next Alt-. to go in the reverse direction. (Just ignore the argument dialog which appears when you press Alt--.)