In zsh
, the key combination Alt+. is bound to insert-last-word
, and it will insert the last argument from previous command on the current command line.
I am looking for a keybinding / shortcut that will act similar to Alt+., except that it will paste all the arguments from previous command on the command line .
I know I can type !*
and zsh will interpret it as "reuse all arguments from previous command". But this is not quite what I am looking for. Also, it does not actually paste the arguments so that I can see them, zsh only interprets !*
as such. I could hit Tab to have it expanded, but that is yet another command necessary.
I would prefer to have this as a key combination such as Alt+something, instead of having to type '!*' and hitting tab
How can I do this ?
UPDATE
After using the widget extensively for few years, I found few things that bother me: (I have the widget bound to Alt + /)
- it works OK once, but when I repeat again, it cycles through my zsh history from the beginning of my
.zsh_history
file.
Instead, I would like the widget to go backwards, from most recent history to the beginning.
- again, when it cycles from the beginning of my zsh history, the space between the command, and the arguments-to-be-completed is removed.
ie:
type some command with arguments:
echo 111 222 333
use widget to complete arguments from previous command:
printf <WIDGET>
printf 111 222 333
above works as expected. But when I press WIDGET again, it suddenly behaves like this:
printf <WIDGET>
printf111 222 333
ie the space between command and argumens was removed
- lastly, I would like to bind another key, for instance Alt+\ to do the reverse, so that when I press Alt + / one too many times, I can go back one step.
!*
expands to all but the first token from the previous history entry, not all arguments from previous command. If the previous entry was(echo foo; echo bar)
,!*
expands toecho foo; echo bar)
notbar
. Is that what you want?