bash/readline equivalent of escape-dot in vi-mode

Viewed 2067

Having recently switched to vi-mode in bash, the one thing I miss is esc . to get the last argument of the last command.

I know about ctrl _, but I always end up hitting ctrl - instead.

Is there another vi-mode equivalent for this?

6 Answers

I believe the closest solution to what you want is this:

In your .bashrc, right after "set -o vi"...

set -o vi
bind -m vi-command ".":insert-last-argument

This tells your bash to invoke the "insert-last-argument" action when '.' is used in vi-command mode. This of course means that you lose the normal "." functionality of VI; but if you are like me, you'll prefer this.

Addendum: You may also want Ctrl-A, Ctrl-E, Ctrl-W and Ctrl-L to work (those were the ones I was missing the most):

bind -m vi-command ".":insert-last-argument
bind -m vi-insert "\C-l.":clear-screen
bind -m vi-insert "\C-a.":beginning-of-line
bind -m vi-insert "\C-e.":end-of-line
bind -m vi-insert "\C-w.":backward-kill-word
Related