Often I'm writing a command in a bash prompt, where I want to get previous arguments, in the CURRENT line I'm typing out, and put in other places in the command.
A simple example, would be if I want to rename a file. I would
- type out the
- type the filename I want to move,
- now I want to just change the extension of the file that I supplied in the first argument, without typing it again.
Can I use history or bash completion in some way to autocomplete that first argument?
$ mv ~/myTestFileWithLongFilename.txt ~/myTestFileWithLongFilename.md
I know of course I could execute the incomplete command, to get it into the history, and then reference it with
!$, but then my history is polluted with invalid commands, and I'm wondering if there's a better way