Workaround: use Brace Expansion: mv /tmp/{file1,.bak} or mv /tmp/{file1,.bak}
It wasn't intuitive, that's why I didn't figure it out in the first place. Autocomplete doesn't work, but this is a bash issue. Still, the placeholder would be kind of more clear but it's an additional feature so you probably WONTFIX it. On Sat, Jul 1, 2023 at 7:23 PM Sergey Ponomarev <stok...@gmail.com> wrote: > Thank you for the fast response. Nice tricks, didn't know about the > direxpand. Probably most regular users don't know either :( > As you may see, even with a workaround this usability can be improved. > So what about having the simple solution in place? > 1. Use placeholder like asterisk to refer the source dir inside of the > dest dir > 2. Use -F arg to create directory if not exists > > Have a nice weekend > > On Sat, Jul 1, 2023 at 6:44 PM Glenn Golden <g...@zplane.com> wrote: > >> >> >> On Sat, Jul 1, 2023, at 09:03, Bernhard Voelker wrote: >> > On 7/1/23 14:12, Sergey Ponomarev wrote: >> > > To rename a file a user need to use mv command and specify the DEST >> dir: >> > > >> > > mv /some/very/long/path/file /some/very/long/path/ >> > > >> > > This makes it not so easy to use when typing a command but also >> makes a >> > > script line longer. >> > >> > Assuming you meant >> > >> > $ mv /some/very/long/path/file /some/very/long/path/file2 >> > >> > as in the other example - this could be done with: >> > >> > $ cd /some/very/long/path && mv file file2 >> > >> > or (with GNU coreutils' env): >> > >> > $ env -C /some/very/long/path mv file file2 >> > >> > Have a nice day, >> > Berny >> >> If you use bash and if your long paths are consistent (i.e. often >> referring >> to the same source or destination each time) then another approach is to >> just >> enable the bash 'direxpand' option, define some short envars in your >> .bash_profile or .bashrc, and use those to facilitate commandline (and >> script) operations, e.g. >> >> export p1=/long/path/to/some/frequently/accessed/directory >> export p2=/another/long/path/to/a/frequently/accessed/directory >> >> Then, for cmdline ops, just typing >> >> $ mv $a/<tab> >> >> immediately expands $a (inline on the commandline) to >> >> $ mv /long/path/to/some/frequently/accessed/directory/ >> >> and you can then tack on "$b" (or any other destination). >> >> The 'direxpand' option provides nice immediate feedback that the envar you >> selected is the correct one (among, presumably, several 1-letter envars >> you've defined like this for various long paths of interest.) >> >> I use this approach frequently in my own workflow when dealing with >> annoyingly long but consistent paths. >> >> Glenn >> >> >> > > -- > Sergey Ponomarev <https://linkedin.com/in/stokito>, > stokito.com > -- Sergey Ponomarev <https://linkedin.com/in/stokito>, stokito.com