Yet another tool for making copy/paste/run experience better (Windows)
github.com
github.com
> 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.
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.
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?)
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.
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.
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.
For small strings, you can paste in Spotlight Search and re-copy to strip formatting.
This is nice when you need multiple items from the same source (say login/password from password manager), instead of doing "copy ; switch ; paste ; switch ; copy ; paste" you can now do "copy ; copy ; switch ; paste ; paste". It's a phenomenal time saver and it will take care of the additional LF at the end, as well!
I've got a quick look and Ditto seem to be capable of doing much more than I personally need, like maintaining the clipboard history (I use Windows' Win+V for that), sharing clipboard over the network and using its own scripting language ChaiScript. OTOH, I'd like to keep the useful functionality of DevComrade at the very bare minimum.
I'm also not sure yet about how exactly they do pasting, i.e., if they use Win32 SendInput. That may affects how well Ditto works with terminals and shells. Conveniently, they provide the source code (looks like it is a C++/MFC project), so at some point I'll come up with a better comparison and update the Readme in my repro.
<hotkey name="InsertGuid" menuItem="Insert &Guid" isScript="true"> <!-- this is an example of a C# scriptlet handler --> <![CDATA[ await Host.FeedTextAsync(Guid.NewGuid().ToString("B").ToUpper(), Token); ]]> </hotkey>