News for hackers. Stuff that matters.
Re:Renaming files with mv without typing the name two times by naikrovek on Monday April 13, 2020 @08:25PM (#22861657)
I love/hate comments like yours.

You have technical knowledge applicable to the problem, and you share it. I love that.

You miss an important feature of the solution shown in (I presume) your rush to demonstrate your bash knowledge: the ability to edit a filename shown, in place. Brace expansion doesn't do that, doesn't show you the new filename before you commit the name change and isn't even close to interactive. This part is less great.

> Something like this isn't really necessary.

It may very well be necessary for someone else.

Re:Renaming files with mv without typing the name two times by Godel_unicode on Monday April 13, 2020 @09:09PM (#22861848)
Not at all, you're just not thinking the solution all the way through. If you want to see the results, an echo gets you there.

The important point though, is that one of the solutions moves you closer to a common language with other posix users, and one moves you farther away. If you use the tools the way they're intended to be used (brace expansion, for example), you'll recognize it when other people use it. You'll understand similar brace expansions in other commands you see others craft. You won't need to remember if that shell you sudo'd into uses your override or not. The reasons go on forever.

It really isn't necessary. That's not to say someone can't think of a reason for it, but rather that there are better ways to do what it does.

Re:Renaming files with mv without typing the name two times by Certhas on Tuesday April 14, 2020 @04:54AM (#22863907)
Personally, I just use a tiny magnet to flip bits on a metal disk. If you want to see the results, you can use an AFM.

You see, a shell really isn't necessary to interact with a computer. The big advantage is that, as you are working on the physical laws they will be the same at any computer you will use! It's the only solution that is universal. No need to remember whether the machine you're working on has Windows or Linux installed!

Sure you can come up with "reasons" to do things differently, but, not by argument, but by fiat, I tell you that they are irrelevant and my way is strictly the better way to do things.

Re:Renaming files with mv without typing the name two times by wruza on Tuesday April 14, 2020 @06:02AM (#22864215)
Who uses that when you have butterflies?

But if one needs to see the name before committing a change, there is https://superuser.com/questions/215950/how-to-expand-on-bash...

Re:Renaming files with mv without typing the name two times by Certhas on Tuesday April 14, 2020 @06:14AM (#22864272)
That's useful, thanks!
Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @06:04AM (#22887797)
Sigh. Nearly every Linux/macOS/UNIX box you run into will have bash or something that will do brace expansion. Same goes for having standard tools like sed, awk, echo, etc.

You can't say the same thing about a bespoke shell function that gives you editable renames.

> Sure you can come up with "reasons" to do things differently, but, not by argument, but by fiat, I tell you that they are irrelevant and my way is strictly the better way to do things.

That's not what anyone is doing and you're attacking a straw man.

Re:Renaming files with mv without typing the name two times by simias on Tuesday April 14, 2020 @07:54AM (#22864805)
I'm all for standardizing tools but when it comes to interactive commands I don't really see the problem to customize for your particular use case. The only drawback is that it makes it a bit more frustrating to use a 3rd party computer but I spend 90% of my time on my own computers where I can easily import my config files.

In this particular instance I also don't find braces much more ergonomic at all. I typically navigate the filesystem using tab completion, that means that I'm going to end up with a full path like:

    mv /foo/bar/some_complicated_file_name.txt |
And then at this point I have to backtrack to add the braces at the right location. In this situation I find TFA's solution more straightforward and more elegant.

I think a more productive advice would be "don't customize something until you've given existing solution a fair chance". It's easy to go overboard with customization and make it counter productive. It's important to understand the mindset of the people who wrote the tools and whether you're truly facing a limitation or the system or if you're "doing it wrong".

For instance I personally love zsh's global aliases and have "G" aliased to "| grep" for instance. So I can write for instance "some_command G something" to grep through the output. I also have "M" bound to "| less". Probably saved me tens of thousands of keystrokes through the years.

Re:Renaming files with mv without typing the name two times by pnutjam on Tuesday April 14, 2020 @09:31AM (#22865676)
no love for the "rename" commmand 'rename foo bar *'
Re:Renaming files with mv without typing the name two times by cyberpip on Thursday April 16, 2020 @09:29AM (#22889126)
It even handles regex (and capture groups!)! I think the issue here though is that it's not always available by default depending on repo.
Re:Renaming files with mv without typing the name two times by titzer on Tuesday April 14, 2020 @01:37AM (#22863028)
For the OP's sake, I hope they completely ignore your advice.

Customize your environment to what makes you the most efficient. Yeah, sure. Learn to use all the things that are there and understand what others do. But customize your environment to what makes you the most efficient. This is an interactive command. It's not like they are going to foist it onto everyone else (which is the true sin, IMHO).

Re:Renaming files with mv without typing the name two times by bb88 on Tuesday April 14, 2020 @02:52AM (#22863348)
Changing the default behavior of a standard posix command is a footgun. It would have been better to rename it.
Re:Renaming files with mv without typing the name two times by Certhas on Tuesday April 14, 2020 @04:59AM (#22863935)
That's a valid constructive critique.

The people who are saying it's not necessary because they prefer alternative ways of interacting with their machine are not arguing that though. The bit the parent replied to was actually claiming that there is no valid reason to do things this way (with a minor bash script) because there are other ways (slightly mysterious curly braces hacks) that do something similar in some cases... which is just, bizarre?

Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @06:07AM (#22887817)
> The bit the parent replied to was actually claiming that there is no valid reason to do things this way

That is not actually what anyone in this thread has claimed.

Re:Renaming files with mv without typing the name two times by kd5bjo on Tuesday April 14, 2020 @05:30AM (#22864082)
'Godel_unicode > That's not to say someone can't think of a reason for it, but rather that there are better ways to do what it does.

'Certhas > The bit the parent replied to was actually claiming that there is no valid reason to do things this way … because there are other ways … that do something similar

It appears to me that you're reading more into 'Godel_unicode's comment than was written. Something not being necessary does not preclude it being useful, and I haven't seen anyone imply otherwise except for you¹. Working through the double-negative, 'Godel_unicode even explicitly acknowledges that some people may have a reason to do things this way, despite their opinion that it's inferior to their method.

¹ I haven't studied the entire thread, so it's likely I've missed someone's comments.

Re:Renaming files with mv without typing the name two times by Certhas on Tuesday April 14, 2020 @06:12AM (#22864256)
I read it as: You can think for a reason to do X but doing Y is strictly better, so your reason is invalid.

I'm pretty sure what the comment doesn't say, also in tone, is something like: Here are two options, X and Y, sometimes you might prefer one, sometimes the other. Specifically look at the comment that Godel_unicode is disagreeing with. That comment points out that some people might prefer the other solution X for their own reason.

The way I read it, Godel_unicode replies that the person who is not using Y is "not thinking things through", and is ignoring infinitely many reasons ("The reasons go on forever.") to do Y. Even though you can come up with "a reason" for X the infinitely many reasons for Y clearly beat it, and thus Y is just objectively better.

Maybe the comment was intended more charitably than I read it.

Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @06:10AM (#22887841)
> I read it as: You can think for a reason to do X but doing Y is strictly better, so your reason is invalid.

I think that's a much more strongly-negative interpretation than the text as written calls for. My original post was nothing of the sort, and the reply I think you're referring to was -- to me -- a nudge toward just simply realizing that the standard tools that already exist are often much more powerful than we think, and we can usually get 90+% of the way there without doing something custom. And the 10% remaining isn't usually worth doing something non-standard unless you have a very niche use.

Re:Renaming files with mv without typing the name two times by titzer on Tuesday April 14, 2020 @02:58AM (#22863373)
> It would have been better to rename it.

Maybe. It's worthwhile pointing out that "mv x" with no second argument is an error:

  mv: missing destination file operand after 'x'
  Try 'mv --help' for more information.
I also don't have the habit of letting people type in my shell, so there's that.

TBH I really don't understand the level of pedantry (and frankly, sheer outrage) in this thread at all. It sucks to be on the receiving end of such disapproval over something so trivial. Let this person do what they want! It's a neat little hack. It also inspired me to see what more I could do with 'read'--something I have ignored for 20 years.

Re:Renaming files with mv without typing the name two times by bb88 on Tuesday April 14, 2020 @03:26AM (#22863495)

    $ mv --help
    Usage: file [OPTION...] [FILE...]
    Determine type of FILEs.
So mv --help now returns the help for the `file` command. You're right, that's not worth warning people at all.

God help any user that's on a shared system whose sysadmin thinks this is a good idea putting in the default /etc/profile.

To be fair, I don't feel like I'm being pedantic. I'm anti-footgun.

Re:Renaming files with mv without typing the name two times by titzer on Tuesday April 14, 2020 @03:51AM (#22863610)
> sysadmin thinks this is a good idea putting in the default /etc/profile

Well that, I agree, would be dumb.

Re:Renaming files with mv without typing the name two times by kilpikaarna on Tuesday April 14, 2020 @11:54PM (#22874339)
You could just filter out anything that begins with a dash and pass it to mv. It seems like mv always interprets that as an option anyway, even if you have a file named --help or whatever.

I like this kind of thing! Minimal code but very elegant from a UX perspective. The oh but you could just mv foo-{bar,baz}.txt crowd is completely missing the point.

Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @06:14AM (#22887872)
> The oh but you could just mv foo-{bar,baz}.txt crowd is completely missing the point.

I disagree. I think a better way to think about things is, "can I accomplish my goal most of the time using the standard tools without writing something custom?" I'll be the first to admit that there are a ton of things in the shell and in coreutils that I don't know about. I bet I've written several scripts over the years with custom functionality that could be replaced with standard tools I didn't know about. That's the thing that I want to avoid.

Re:Renaming files with mv without typing the name two times by bb88 on Wednesday April 15, 2020 @03:37AM (#22875457)
I love bash. I love unix/linux. I love that bash gives you that kind of power. I love the fact that he figured out a nifty way of doing this.

But please please please please with all the love of America, baseball, and apple pie, don't change the default behavior of basic unix commands.

Otherwise you force people into writing nonsense like this:

MV=/usr/bin/mv

${MV} ${FILE1} ${FILE2}

Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @06:11AM (#22887849)
> (and frankly, sheer outrage)

I think you're reading way too much into what I and others are saying. Honestly I'm finding being misunderstood and mis-characterized as angry to be the only thing that's bothering me.

Re:Renaming files with mv without typing the name two times by hrktb on Tuesday April 14, 2020 @03:50AM (#22863600)
> Customize your environment to what makes you the most efficient.

This is a valid advice, but on a fundamental level, how is it better or worse than "Learn to be the most efficient for your environment" ?

IMO it comes down to which is harder/expensive, changing yourself or your environment, and on this site in particular, I don't think there is a clear consensus on one or another.

Re:Renaming files with mv without typing the name two times by titzer on Tuesday April 14, 2020 @03:56AM (#22863634)
> changing yourself or your environment

After more than 25 years of using software, IMHO it's a losing battle to try to change the environment around you. It's also a losing battle to try to change yourself. You'll never keep up in the long run. After a while the pace of change becomes so rapid, and change comes from every corner at every level. Eventually what you once knew becomes useless and outdated. You can keep up to some extent, but be prepared for a lifetime of unpleasant surprises.

What works, IMO, is instead to build an environment around yourself that works for you, that protects you from the things changing that you can't control. An internal abstraction layer, a bubble. Then when the bubble breaks in little pinpricks and starts crumbling, you can repair the internal environment to be pretty much what it was before. So by all means, make your own little commands and scripts and stuff. Get cozy, but try to pick your battles wisely on what you will depend.

Re:Renaming files with mv without typing the name two times by hrktb on Tuesday April 14, 2020 @04:49AM (#22863879)
Hat's off on your 25 years!

Some of us are doing crazy stack switches mid-carrier, so maintaining a bubble around us can be a difficult option. I remember being day-in-day-out in Eclipse doing Java, and switching to a different stack meant throwing it all through the window and finding out what were the most optimized tools for the new set of tasks that will be done hundreds of time a day.

I see the same thing happening with people switching away from iOS dev for instance.

But I also agree we are in a privileged positions where on most tools we can build ourselves the layers to make it look/behave like familiar things. Especially for tools like bash or vim that purposefully change at a glacier pace compared to the rest of the stack.

I guess we usually take both approaches of learning new things to be more efficient and also building/customizing things as we see the parts where we don't want/can't change our behavior.

> Get cozy, but try to pick your battles wisely on what you will depend.

I like this phrasing a lot; nicely put.

Re:Renaming files with mv without typing the name two times by dvfjsdhgfv on Tuesday April 14, 2020 @06:29AM (#22864382)
That's feasible only in some scenarios. Nowadays you often need to interact with new environments and be instantly productive in them. Also, it makes little sense trying to receate the same cozy environment between, say, EC2, WSL and FreeBSD hosts when you need to interact with them for a very short time. Welcome to the era of disposable computing.
Re:Renaming files with mv without typing the name two times by Kaiyou on Tuesday April 14, 2020 @07:51AM (#22864793)
This only works when you are strictly working with one machine that is your own, instead of many machines, that are not your own. Customizing every machine I touch is more hassle than to just master the tools that are already in place.
Re:Renaming files with mv without typing the name two times by sullyj3 on Wednesday April 15, 2020 @06:53PM (#22884107)
There seems to a large contingent of linux users who are somehow completely immune to garbage user experience. It's really impressive.
Re:Renaming files with mv without typing the name two times by Kiro on Tuesday April 14, 2020 @02:58AM (#22863374)
I don't use bash for ideological reasons. I use it to get things done and I much rather prefer this script than having to use curly braces and echo.
Re:Renaming files with mv without typing the name two times by ehnto on Tuesday April 14, 2020 @05:25AM (#22864062)
Out of curiosity, what are you reasons for not using bash?
Re:Renaming files with mv without typing the name two times by oddeyed on Tuesday April 14, 2020 @06:00AM (#22864205)
I think they mean that they do use bash, but the reason that they use it is not ideological. Tricky sentence to work out.
Re:Renaming files with mv without typing the name two times by ehnto on Tuesday April 14, 2020 @07:03AM (#22864587)
Oh, you're right. Honestly had I truly read the whole sentence I probably would have figured that out.
Re:Renaming files with mv without typing the name two times by Delfino on Tuesday April 14, 2020 @06:01AM (#22864213)
As I understood their comment, they do use bash but not for any ideological reason but rather to get things done.
Re:Renaming files with mv without typing the name two times by kazinator on Monday April 13, 2020 @09:03PM (#22861818)
> doesn't show you the new filename

  $ echo mv foo{x,y}bar
> the ability to edit a filename shown, in place

Easily done right in the command line. First, type this:

  $ mv oldname _ 
The _ denotes the cursor.

Now erase the last word using Ctrl-W:

  $ mv _
Now pastte it twie with Ctrl-Y Ctrl-Y:

  $ mv oldname oldname _
Edit in place, submit.
Re:Renaming files with mv without typing the name two times by matt-attack on Monday April 13, 2020 @09:24PM (#22861932)
Using echo is the wrong way. What you do is ‘CTRL-x *’. That will expand any glob right there on the command line.
Re:Renaming files with mv without typing the name two times by kazinator on Monday April 13, 2020 @09:31PM (#22861966)
Brace expansion isn't a glob, unfortunately. Did you try it?
Re:Renaming files with mv without typing the name two times by bruce_one on Tuesday April 14, 2020 @12:45AM (#22862830)
I didn't know the `CTRL-x * ` expansion; it appears to work in zsh for brace expansion:

  $ touch asdf-{gh,jk}-l
  # CTRL-x *
  $ touch asdf-gh-l asdf-jk-l
Re:Renaming files with mv without typing the name two times by tsbinz on Tuesday April 14, 2020 @04:39AM (#22863828)
In zsh you can use tab to expand globs/braces/variables as well.
Re:Renaming files with mv without typing the name two times by m463 on Tuesday April 14, 2020 @08:00AM (#22864838)
I didn't know about that.

I tried control-x escape, that only does variable expansion (and it appears to expand aliases too)

Re:Renaming files with mv without typing the name two times by Kiro on Tuesday April 14, 2020 @03:00AM (#22863378)
Or I just use this script which is much more intuitive and convenient.
Re:Renaming files with mv without typing the name two times by kazinator on Tuesday April 14, 2020 @03:59AM (#22863642)
In my other post, I got the readline method down to one control code. You type "mv name" and hit the assigned control character, which produces a second copy of the name that you can edit in place. It works with any command: mv, cp, ln, git mv ... The editing is in the same command line, resulting in a proper argument that is in the command line. It gets saved into your history, and can be pasted into a script.
Re:Renaming files with mv without typing the name two times by zeepzeep on Tuesday April 14, 2020 @03:31AM (#22863513)
But only solves one use case. Why not learn how to do it for every other unix tool?
Re:Renaming files with mv without typing the name two times by Kiro on Tuesday April 14, 2020 @05:17AM (#22864025)
I don't see how this script prevents me from learning it. With that said, we're obviously in different ballparks when it comes to the terminal. I don't need to do anything fancy. cd, ls, mv and git are pretty much the only commands I ever use. For me, this script fits nicely into my workflow.
Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @06:18AM (#22887894)
But it's... not? What if I want to use the same trick with 'cp'? Do I go and copy-paste my script, or maybe spend time to make it generic enough to handle both commands? That's not a good use of my time when the shell will do it for me, if only I'd spend a minute to learn.
Re:Renaming files with mv without typing the name two times by adito on Tuesday April 14, 2020 @02:10AM (#22863172)
Agree with you. Said in another word, "Their statement is correct but misses the point"[1]

[1]: https://news.ycombinator.com/item?id=22854475

Re:Renaming files with mv without typing the name two times by mrb on Tuesday April 14, 2020 @03:11AM (#22863426)
Interactively editing the filename is possible with this even simpler solution:

  mv foo.txt 
  ↑
  Alt-.
This works in bash and any shell using readline. Explanation: https://news.ycombinator.com/item?id=22863402
Re:Renaming files with mv without typing the name two times by bJGVygG7MQVF8c on Wednesday April 15, 2020 @04:55PM (#22882941)
Great tip thanks!

Similarly, readline's vi mode makes interactive editing in place easy

Re:Renaming files with mv without typing the name two times by ivanhoe on Tuesday April 14, 2020 @10:37AM (#22866521)
> You miss an important feature of the solution shown in (I presume) your rush to demonstrate your bash knowledge: the ability to edit a filename shown, in place.

OK, then just use !#$ (the last word of the current command) and press CTRL + ALT + e to expand it into the actual value.

Re:Renaming files with mv without typing the name two times by graywh on Monday April 13, 2020 @09:10PM (#22861850)
Zsh can expand expansions before you execute a command
Re:Renaming files with mv without typing the name two times by markstos on Monday April 13, 2020 @09:07PM (#22861837)
At least with the `fish` shell, you can use "Alt-E" to edit any command line. It's a visual, interactive, re-usable solution that shows the result before you commit it.
Re:Renaming files with mv without typing the name two times by Lio on Tuesday April 14, 2020 @04:55AM (#22863910)
Is that different to bash or zsh?

Both support editing using either vi or emacs shortcuts via readline.

Re:Renaming files with mv without typing the name two times by bJGVygG7MQVF8c on Wednesday April 15, 2020 @04:52PM (#22882904)
> (I presume) your rush to demonstrate your bash knowledge

Heaven forbid someone share knowledge. Let's interpret as uncharitably as possible and passive-aggressively love/hate.

> Brace expansion doesn't do that, doesn't show you the new filename before you commit the name change

Allow me to rush to demonstrate my zsh knowledge for any passersby who might benefit:

% mv foo-bar-{bar,baz}.txt|[TAB]

% mv foo-bar-bar.txt foo-bar-baz.txt

Re:Renaming files with mv without typing the name two times by kesor on Monday April 13, 2020 @09:18PM (#22861894)
In my `set -o vi` bash I can type `v` to edit the command in vim before executing it.
Re:Renaming files with mv without typing the name two times by bnegreve on Monday April 13, 2020 @11:07PM (#22862405)
For the record, you can do this with C-x C-e without vi keybindings
Re:Renaming files with mv without typing the name two times by pknopf on Tuesday April 14, 2020 @01:26AM (#22862990)
The more I read these comments/suggestions, the more I realize I'm bash'ing like a child. I seriously need to embrace my shell a little more.
Re:Renaming files with mv without typing the name two times by rmetzler on Tuesday April 14, 2020 @02:11AM (#22863176)
Same for me. I knew the bash has emacs bindings and I know just enough to go to beginning, end, delete a word, etc. but I never knew you can start emacs with a shortcut like this. How do you even exit emacs properly?
Re:Renaming files with mv without typing the name two times by bnegreve on Tuesday April 14, 2020 @03:43AM (#22863571)
C-x C-s to save, C-x C-c to quit.

But you can also control which editor is going to be used to edit your command line by setting the EDITOR environment variable.

It also works for git, and other commands that need to spawn editors.

Re:Renaming files with mv without typing the name two times by m463 on Tuesday April 14, 2020 @07:55AM (#22864811)
I never knew that existed.

My first thought was "emacs editing characters already work on the command line."

Then I thought, maybe there are commands you want to be really really sure of before submitting them?

Then I realized I very frequently use very long commands with loops and pipes that might benefit, like:

  for i in *.py; do mv $i AA_$i; done
or a little of both:

  find . -type f |while read f; do if cmp -s "$f" ../new/"$f"; then rm -f "$f"; fi ;done
(thanks!)
Re:Renaming files with mv without typing the name two times by kelnos on Thursday April 16, 2020 @05:59AM (#22887768)
> in (I presume) your rush to demonstrate your bash knowledge

It's unfortunate that you reach for the uncharitable explanation first. To return the favor, I assume you rushed to post your reply because you think being contrarian and chastising the top-rated comment will get you more karma points? See, that wouldn't be cool... of course I don't actually believe that. While I don't agree with you, I assume you're arguing in good faith!

The simple fact is that I just don't see the need for it; after many years of heavy command-line use, I wouldn't use a tool like this. Either the simple case is sufficient, or I need something much more advanced, like prefix/suffix/regex replacement across multiple files (in which case shell variable expansion will often work, or I'll reach for `sed`). Beyond that, I try to avoid getting used to tools that only exist on my machine, and not on the tens of machines I ssh to weekly. (I already sometimes find myself, for example, attempting to use ripgrep on remote hosts that don't have it, and it's annoying.)

If you look downthread a bit, there are several comments that expand on doing it the "built-in" way that covers the original use case even more. For example:

Type "mv foo.txt" -> hit ctrl+w (cut word) -> hit ctrl+y (paste word) twice -> use arrow keys to edit.

Someone else mentioned fish will expand braces if you hit the <tab> key.

There are so many cool built-in things that the shell can already do for you; writing up a hacky solution that only works for one use case (the methods mentioned above work for mv, cp, ls, etc.) is limiting your learning and wasting your time.

> It may very well be necessary for someone else.

I really wish people would understand that when people make statements like I did, there's an implicit "for me" or "in my experience" tacked onto the end of that. Yes, obviously, people have different needs, and yes, obviously, I am talking about my own personal experience and needs. But I really do think that shell brace expansion covers the 90% case, and I was under the -- perhaps mistaken -- impression that the OP may not have known about it, or realize how it can be useful in this particular context. I knew about this sort of shell expansion for many years before I saw someone using it to do a file rename, and it was a big "wow, how have I never thought of that?" moment for me at the time; I expect that sort of thing happens to a lot of people.

Re:Renaming files with mv without typing the name two times by xorcist on Tuesday April 14, 2020 @06:59AM (#22864563)
Interactive editing is generally something to avoid. It can't be part of a bash script, or a puppet manifest, or checked into version control.

In the cases where you need to do interactive edits of file names, something like emacs or mc is probably less error prone than bash.

Re:Renaming files with mv without typing the name two times by b0rsuk on Tuesday April 14, 2020 @02:31AM (#22863261)
If interactive editing is the big win, you can install 'mc' and it will give you many more interactive editing capabilities.

Renaming via bash expansion has the additional advantage that it's script-friendly.

Re:Renaming files with mv without typing the name two times by dgl on Tuesday April 14, 2020 @02:38AM (#22863285)
I really like that zsh can be set to expand globs on tab, both useful for editing when a glob is “close enough” and for checking the result quickly. I think a lot of the value of a script like this is you don’t have to switch contexts or think any different before you use it.
Re:Renaming files with mv without typing the name two times by mehrdadn on Monday April 13, 2020 @09:06PM (#22861829)
Not just that, but the time it takes me to get the braces correct is usually more than it takes me to just select the damn thing with a mouse, paste it, and modify it...
Re:Renaming files with mv without typing the name two times by mekazu on Tuesday April 14, 2020 @08:00AM (#22864842)
Could use mv -iv for interactive and verbose if you want a rollback or commit alternative.

The real question is: why move files at all?

Re:Renaming files with mv without typing the name two times by ComodoHacker on Tuesday April 14, 2020 @09:19AM (#22865537)
For the same reason you move stuff in your room. You don't always put it into right places. Or someone else has put it somewhere.
Re:Renaming files with mv without typing the name two times by arkaic on Monday April 13, 2020 @09:19PM (#22861902)
Also, typing braces are annoying. To think about it from a UX perspective, this solution on gist, judging by the video, is perfect.
Re:Renaming files with mv without typing the name two times by qplex on Monday April 13, 2020 @09:45PM (#22862020)
Let me just say that typing {}[] is super painful on many international variants of QWERTY. Typically you need to press a modifier for both (Alt Gr).

https://en.wikipedia.org/wiki/QWERTY#International_variants

Re:Renaming files with mv without typing the name two times by izolate on Monday April 13, 2020 @11:00PM (#22862359)
Which is why if you're a programmer, you're doing yourself a disservice by not using a keyboard with a US layout.
Re:Renaming files with mv without typing the name two times by llarsson on Monday April 13, 2020 @11:49PM (#22862588)
Full agreement from me. My ergonomics and efficiency both improved immensely when I switched from my native layout to US International.

With US International, unless I want to hit the key combo to change layouts, I can still write a single or just a few umlauts (say, for a person's name).

I find it easier to keep my focus when I don't have to make the right wrist twister that is otherwise required for { if using a Swedish layout.

Re:Renaming files with mv without typing the name two times by read_if_gay_ on Tuesday April 14, 2020 @01:33AM (#22863009)
Also try setting caps as compose key and using the standard ANSI layout. Solves the problem of always having to double press characters such as quotes.
Re:Renaming files with mv without typing the name two times by Symbiote on Tuesday April 14, 2020 @01:45AM (#22863073)
Minor point: or the UK layout, for a European keyboard (ISO keyboard) with the tall enter key, rather than the American ANSI layout with a wide enter.

The extra key on the UK layout brings # without shift, which is useful, and £ and ¬ which presumably aren't, but could be remapped to something more useful like € and an accent.

Re:Renaming files with mv without typing the name two times by Lio on Tuesday April 14, 2020 @05:04AM (#22863964)
As a UK user I switched to an alternative layout many years ago for RSI reasons. My preference is Colemak but I don't think it matters too much which layout you opt for.

For me the advantage, other than less finger travel, is that the markings on the keys don't match the layout I use. I've been forced a long time ago to commit it all to memory and learn to touch type without looking at the keyboard.

Touch typing is a small thing but is a massive productivity boon just on it's own even if you're not a speed daemon because you don't have to think to type.

Re:Renaming files with mv without typing the name two times by rhizome on Tuesday April 14, 2020 @04:14PM (#22870889)
Touch typing is not a small thing.
Re:Renaming files with mv without typing the name two times by mkl on Tuesday April 14, 2020 @08:58AM (#22865280)
UK layout makes it hard to press enter or left shift. I find it frustrating and bad for my joints.
Re:Renaming files with mv without typing the name two times by Symbiote on Tuesday April 14, 2020 @02:50PM (#22869905)
I'm only suggesting it for people already used to that physical layout of the keys. Germans, French, Spanish, Swedish etc.

It means they can continue to use normal keyboards (including on laptops) in their country.

Re:Renaming files with mv without typing the name two times by Tistron on Tuesday April 14, 2020 @03:06AM (#22863404)
I totally agree with this. Another problem are some programs where shortcuts seem to bind to some hardware codes of keys instead of what your layout says, so that shortcuts aren't what they say they are, e.g ctrl+[ would be at ctrl-å instead of ctrl+altGr+9 on a swedish keyboard (which I guess couldn't work because altGr is the same as ctrl+alt, or is that not true?)

In my situation I write in english, swedish, danish and sometimes icelandic as well as in programming languages. My solution has been to create my own keyboard layout that I call Nordic Programmer which is the US keyboard but by pressing altGr I have åäö letters where they are supposed to be, and øæ next to them. and then on altGr+eyuioadt i have éýúíóáðþ for icelandic. All of them are capitalized by adding shift. This was pretty easy to learn to use and makes me not have to switch keyboard all the time. It is not truly nordic I guess, because it prioritizes swedish which is the keyboard I learned growing up.

Re:Renaming files with mv without typing the name two times by kps on Tuesday April 14, 2020 @11:53AM (#22867487)
> shortcuts seem to bind to some hardware codes of keys instead of what your layout says

You don't say what platform you use, but this can be true of Windows and Windows-derived systems (which includes a lot of web stuff on all platforms because Netscape foolishly exposed Windows internal key codes 25 years ago). The non-alpha VK (virtual key) codes migrate all over the place¹ or worse disappear (e.g. Turkish doesn't have the VK corresponding to US +/= at all).

I used to work on Chrome OS which currently does this (trying very hard to emulate the Windows rearrangements due to the Netscape web legacy) but will shortly try the “what they say they are” method behind an experimental flag; that is, for example, the shortcut Ctrl+[ would be typed by Ctrl plus whatever you type to get ‘[’.

¹ http://kbdlayout.info/

Re:Renaming files with mv without typing the name two times by Tistron on Wednesday April 15, 2020 @03:08AM (#22875317)
Yes, it's on Windows I have experienced this issue.

I'm not familiar with the low level mechanics of this but you seem to be. How would it work to do what you write at the end? Isn't altGr just an easier way of typing ctrl+alt? Getting ctrl+[ would then be ctrl+ctrl+alt+9. Or is it a proper key of its own?

Re:Renaming files with mv without typing the name two times by kps on Wednesday April 15, 2020 @11:58AM (#22879293)
AltGraph is physically the key that is right-Alt on US keyboards. My understanding is that Windows has Ctrl+Alt as an alternative because some long ago PS/2 keyboards didn't distinguish the two Alt, so it wouldn't be able to take the same approach.
Re:Renaming files with mv without typing the name two times by RMPR on Tuesday April 14, 2020 @01:38AM (#22863032)
Couldn't agree more, was using the French layout and while learning vim I always asked myself what are those weird keybindings, switching to US layout, they suddenly started to make sense because the keys are more reachable without the usual gymnastic.
Re:Renaming files with mv without typing the name two times by lkuty on Tuesday April 14, 2020 @02:45AM (#22863317)
So true. In a month I will receive my new laptop with a qwerty US layout instead of the belgian azerty one I used until now. Using an external keyboard for now, I already see the benefit of qwerty for programmers. And I also switch from macOS to Linux with i3wm.
Re:Renaming files with mv without typing the name two times by GonzaloQuero on Tuesday April 14, 2020 @05:18AM (#22864034)
I never understood why most programming languages where so heavy in brackets until I moved to the UK and saw the layout. Then it clicked.
Re:Renaming files with mv without typing the name two times by wolco on Monday April 13, 2020 @10:36PM (#22862242)
From a UX perspective use a gui file explorer, double click rename.