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 !$ and $_, 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
bash, but byksh. This one too;$_is expanded inksh. It might be worth a thought to switch toksh; one gains not only many useful features but also a lot performance. And specificallybash's (vi-mode) history functions are not solved in an acceptable way, specifically if compared toksh. Recentkshversions have even abashcompatibility mode - not that I'd suggest to use it, though. (Just a suggestion. I'm aware that Linux users often just use what GNU provides.)