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?
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
You can also use the following to restore the emacs "escape-dot inserts last argument" behaviour in vi mode:
bindkey -v '\e.' insert-last-word
To restore certain bash goodies in vi-mode, simply alter or add ~/.inputrc like this:
set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
set editing-mode vi
set keymap vi-insert
$if mode=vi
"\C-a": beginning-of-line
"\C-e": end-of-line
"\C-l": clear-screen
"\C-n": next-history
"\C-p": previous-history
"\C-w": backward-kill-word
"\e.": yank-last-arg
"\e_": yank-last-arg
$endif
Here are more bindable readline bash commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With