Skip to main content

History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument, $, to get the parameter you just typed.

And you can use all the regular modifiersmodifiers over it, so if, e.g., you are renaming a file in a far-away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname

History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument, $, to get the parameter you just typed.

And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far-away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname

History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument, $, to get the parameter you just typed.

And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far-away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname
add links to documentation
Source Link
Matthias Braun
  • 8.8k
  • 8
  • 51
  • 63

History expansion actually works on the current command as well, using the event designatorevent designator !#. Combine this with the word designatorword designator for the last argument -, $ -, to get the parameter you just typed. 

And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far away-away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname

History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument - $ - to get the parameter you just typed. And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname

History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument, $, to get the parameter you just typed. 

And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far-away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname
Source Link
qwertyboy
  • 411
  • 4
  • 5

History expansion actually works on the current command as well, using the event designator !#. Combine this with the word designator for the last argument - $ - to get the parameter you just typed. And you can use all the regular modifiers over it, so if, e.g., you are renaming a file in a far away directory, you can just type:

mv path/you/do/not/want/to/type/twice/oldname !#$:h/newname