I often need to create copy of files in varios locations(, and want to avoid excessive typing). (Then I will edit them)
Basically commands are like:
cp very/long/path/to/file/my-file_with-long.name very/long/path/to/file/my-file_with-long-another.name
vim very/long/path/to/file/my-file_with-long-another.name
cp even/longer/path/to/other/location/with_another-file_and-stupid.name even/longer/path/to/other/location/with_another-file_and-stupid-copy.name
vim even/longer/path/to/other/location/with_another-file_and-stupid-copy.name
I really want to avoid changing workdir with cd
and typing the same path twice. Basically I can add command into bashrc
like mydup
, so it will create new file and return its name, so I cam use:
vim $(mydup very/long/path/to/file/my-file_with-long.name -another)
vim $(mydup even/longer/path/to/other/location/with_another-file_and-stupid.name -copy)
But maybe I invent bicycle and there is easier way to do the same?
or
You can copy a file in-place, without changing directories. E.g.
In this case, bash-completion and
tab
key is your friend. I do it all the time and I never write too much.