10
8
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 Ctrl
-r
, you can change directions with Ctrl
-s
. What is the analogue for Alt
-.
?)
Thank you! I have been wondering how to do this for ages. – dotancohen – 2014-12-02T10:38:58.340
1I'm not sure what you mean exactly. Pressing
Alt
+-
removes the command-line prompt and inserts(arg: -1)
instead. The command itself is unchanged. – Sparhawk – 2013-05-12T06:23:55.4001Thenext alt-. (with the -1 arg) will go forwards. – rici – 2013-05-12T06:46:21.770
That's great! I've edited the answer to make it a bit clearer. What does
alt
+-
do exactly? – Sparhawk – 2013-05-12T12:35:42.9031@Sparhawk: as I said,
alt
-
produces an argument of-1
for the next readline command. Or, more precisely, it starts a negative argument, soalt
-
, alt2
would produce an argument of
-2. In the case of
alt.
, only the sign of the argument matters, and only if it is negative, so
alt-
is sufficient. (The first
alt.` handles its argument differently. See the bash manual.) – rici – 2013-05-12T16:12:46.417
Thank you. I often find
man bash
slightly opaque for such situations, but I think it's clarified it a little here. – Sparhawk – 2013-05-14T02:22:05.167