Is there any shortcut to reference the path of the first argument in a MV command?
And another way: brace expansion.
mv app/models/keywords_{builder,generator}.rb
In general,
before{FIRST,SECOND}after
expands to
beforeFIRSTafter beforeSECONDafter
So it's also useful for other renames, e.g.
mv somefile{,.bak}
expands to
mv somefile somefile.bak
It works in bash
and zsh
.
More examples:
You can use history expansion like this:
mv app/modules/keywords_builder.rb !#^:h/keywords_generator.rb
!
introduces history expansion.#
refers to the command currently being typed^
means the first argument:h
is a modifier to get the "head", i.e. the directory without the file part
It's supported in bash
and zsh
.
Docs: