When using bash's vi mode (set -o vi), is it possible to recover the last argument of the last executed command? This is done in emacs mode with ESC+., and I would like to do it in vi mode as well.
I know that bash provides
$_, but they are not expanded and I find quite dangerous to use them directly.
I've tried (with no success) some solutions I found on Stack Overflow about editing the
.inputrc and adding:
set editing-mode vi set keymap vi-insert "\e.": yank-last-arg "\e_": yank-last-arg
I'm switching to vi mode in bash but I'm quite used to ESC+. and it would be nice to be able to use it, or to find a quick & easy replacement.
EDIT: This question has been marked as a duplicate of a similar one that asks about how to recover last argument with Alt+S. I was asking specifically about ESC+. (it's the shortcut I'm used to and it is not covered by the other answer).
EDIT: To complement @chaos' solution: the following binding makes ESC+. (well, really '.') paste the last argument, but you lose Vi's dot (.) functionality:
bind -m vi-command ".":insert-last-argument