I ran across a post by James Dyer, Dired Duplicate Here Revisited, that was interesting and I thought was worth writing about but I wasn’t sure there was enough there for a post. Then I saw this post by Álvaro Ramírez and thought they complemented each other and together can serve as the basis for my own post.
It turns out that Ramírez had the same thought and that his post was inspired by Dyer’s. It started with Dyer wanted a quick way to duplicate a file in a Dired buffer. His workflow results in a frequent need to do this so it made sense to make it as frictionless as possible. His code to do this is simple and straightforward.
Ramírez, of course, extended the idea by including it in his dwim-shell-command
framework. He uses Bozhidar Batsov’s crux-duplicate-current-line-or-region
that duplicates a line or region. It’s similar to Joe Casadonte’s and Steve Purcell’s whole-line-or-region that I use. In any event, he leveraged his muscle memory for that by using it to invoke his dwim-shell-command
template to duplicate one or more files in a Dired buffer.
If you also have a need to duplicate one or more files in a Dired listing, take a look at these two posts. They present two excellent solutions.