How to repeat the last part of a previous command?
I just tested and it seems you can do it the same way as in bash: !$
.
Wether you are in bash or zsh, you can use the !
operator to recover arguments of your previous command:
If we take: echo a b c d
as an example
-
!$
- the last argument: d -
!:*
- all the arguments: a b c d (can be shorten!*
) -
!:1
- the first argument: a (same as!^
) -
!:1-3
- arguments from first to third: a b c -
!:2-$
- arguments from the second to the last one: b c d
This last point answer you question, you can take the last part of your command.
Note: !:0
is the last command executed, here it would be echo in our example