News for hackers. Stuff that matters.
Re:Yet another tool for making copy/paste/run experience bet... by AnonHP on Friday August 07, 2020 @09:25AM (#24081521)
To the author: This is a really nifty tool. It's also great that it provides the ability to configure custom keyboard shortcuts. I will be trying this soon.

> Does the following sound familiar: you paste some text from a web page into a Terminal command line, and it gets executed immediately, before you even had a chance to edit it? Only because there was a CR/LF character at the end of the clipboard text.

Oh yes, that sounds very familiar! As the description says, I use another buffer (it says notepad.exe) to re-copy the line without the newline and then paste. __________

Aside: Is there a similar tool for macOS?

__________

The screenshot also shows a "Prevent Sleep Mode" option. I currently use an app called Caffeine [1] to keep my machine awake (and not automatically lock). I guess DevComrade could replace that too.

[1]: https://zhornsoftware.co.uk/caffeine/

Re:Yet another tool for making copy/paste/run experience bet... by JadeNB on Friday August 07, 2020 @10:25AM (#24082196)
> Aside: Is there a similar tool for macOS?

I don't know the state of Windows terminal emulators, but it seems strange to describe the problem without mentioning the term for the solution, which is 'bracketed paste'. This article discusses how bracketed-paste mode is signalled using ANSI escape sequences, which I guess can work in most macOS terminal emulators (although it's up to the shell to respond): https://cirw.in/blog/bracketed-paste . (I guess that Win+Ins is doing something similar on Windows?)

Re:Yet another tool for making copy/paste/run experience bet... by AnonHP on Friday August 07, 2020 @11:16AM (#24082758)
Thanks for this. I’ll check out bracketed pasting mode in terminal next time (not near one right now), though I have to admit that even after reading that post, I didn’t understand what exactly happens when it’s used. I understood that the command does not get executed, but what happens in the shell (I looked this up on Wikipedia too)? Does it just display the line and allow the user to edit it so that the starting and ending escape sequences can be removed along with any other edits and then the command executed?
Re:Yet another tool for making copy/paste/run experience bet... by JadeNB on Friday August 07, 2020 @11:31AM (#24082964)
> I understood that the command does not get executed, but what happens in the shell (I looked this up on Wikipedia too)? Does it just display the line and allow the user to edit it so that the starting and ending escape sequences can be removed along with any other edits and then the command executed?

My understanding is that it's up to the shell, or whatever program, to decide how to handle it. (I didn't make this clear in my original post, and have updated it accordingly.) All bracketed paste is doing is providing a mode that tells the program "everything between these two symbols should be interpreted as input, not as commands"; it's then up to the program to decide how it wants to respond to the user's intention.

At least for me, with Terminal.app and bash 5.0 (where it's not enabled by default), it behaves es you describe when enabled by `set enable-bracketed-paste on` in `.inputrc`. For vim, I believe the plugin is essentially doing the equivalent of `set paste` before and `set nopaste` after.

Re:Yet another tool for making copy/paste/run experience bet... by noseratio on Friday August 07, 2020 @11:14AM (#24082743)
> I guess that Win+Ins is doing something similar on Windows?

By default Win+Ins does nothing on Windows. I had to implemented this feature in DevComrade. I wish it was all part of Windows so I didn't have to maintain it :) Happy if they take the source, it's an Apache 2.0 license.

Re:Yet another tool for making copy/paste/run experience bet... by noseratio on Friday August 07, 2020 @09:33AM (#24081598)
Thanks! Prevent Sleep Mode is on my TODO list, same as publishing to Windows Store. I'm not sure if there's a similar tool for MacOS. If there isn't, that'd be a bit of a learning curve for me to implement it :)
Re:Yet another tool for making copy/paste/run experience bet... by TheSpiceIsLife on Friday August 07, 2020 @10:00AM (#24081886)
I ctrl-L / cmd-L to the URL bar in the browser and do the re-copy from there.
Re:Yet another tool for making copy/paste/run experience bet... by GordonS on Friday August 07, 2020 @02:20PM (#24084930)
I did something similar for years, but using the Windows 'run' dialog instead, so I'd select the text, CTRL-C, WIN-R, CTRL-V, CTRL-A, CTRL-X, and then paste in the now unformatted text where I wanted it. Sounds convoluted, but after doing it a few times, muscle memory made it really fast, 2s or so.

I discovered PureText a good while back (mentioned by the author), which instead let's me bind WIN-V to paste the current clipboard as unformatted text. Unfortunately the functionality has been a bit unreliable because of Windows updates, so I'll be giving this a try.

Re:Yet another tool for making copy/paste/run experience bet... by noseratio on Friday August 07, 2020 @10:12AM (#24082019)
I used to hit Alt+D or Win+R for that. But now I can do Win+Ins and it pastes a single unformatted line without line breaks anywhere. Works very well for me in the command line, especially when remoting with SSH.
Re:Yet another tool for making copy/paste/run experience bet... by noseratio on Friday August 07, 2020 @09:36AM (#24081619)
Also, DevComarade already has a shortcut for Presentation Mode, which just launches Presentationsettings.exe, but that should too keep you PC awake and without locking the screen, if that's what your want.
Re:Yet another tool for making copy/paste/run experience bet... by reaperducer on Friday August 07, 2020 @01:38PM (#24084524)
Aside: Is there a similar tool for macOS?

If you use iTerm on macOS, a disclosure sheet will ask if you really want the whole thing with the CR, or if you just want the regular text.

Re:Yet another tool for making copy/paste/run experience bet... by zzapplezz on Friday August 07, 2020 @01:51PM (#24084645)
> Aside: Is there a similar tool for macOS?

For small strings, you can paste in Spotlight Search and re-copy to strip formatting.

Re:Yet another tool for making copy/paste/run experience bet... by jaytong on Friday August 07, 2020 @02:08PM (#24084819)
Not sure if it works everywhere, but I normally do Cmd + Shift + V