olfway Posted October 14, 2023 Share Posted October 14, 2023 For me it would be very useful if Alfred would strip whitespaces (spaces, tabs, newlines, maybe something else) from text on copy or paste Link to comment Share on other sites More sharing options...
sepulchra Posted October 14, 2023 Share Posted October 14, 2023 you should be able to accomplish this with combinations of automation tasks (look under text processing) and the copy to clipboard object. Link to comment Share on other sites More sharing options...
Stephen_C Posted October 14, 2023 Share Posted October 14, 2023 In addition to sepulchra's helpful suggestion note that the Transform workflow utility will trim whitespace and newlines. Stephen Link to comment Share on other sites More sharing options...
olfway Posted October 14, 2023 Author Share Posted October 14, 2023 Thanks for your suggestions! If I understand correctly then I have two options with workflows – run workflow for copy to clipboard or run workflow to paste, right? If I would run workflow to paste then I'll miss alfred's clipboard history viewer, so that's not an option So it seems the only way I can use it – create a workflow to get current selection, strip whitespaces from it and paste it to clipboard and assign it to cmd+c hotkey But there will be a problems here – sometimes I want to copy images or files and sometimes I copy via menu instead of hotkey and sometimes iTerm itself copies selection to clipboard Probably if Alfred would have a trigger like "text content copied to clipboard" and output like "replace content in clipboard history" then I would be able to make a workflow which would work. But actually I think that whitespace trimming is so basic feature, so it could be added as a feature to alfred's clipboard manager itself Link to comment Share on other sites More sharing options...
Stephen_C Posted October 14, 2023 Share Posted October 14, 2023 Although it's not exactly what you want you may find this Alfred help page useful: Using Clipboard History Items In Workflows and Snippets. It would, for example, allow you in a workflow to recall the last item pasted to the clipboard and strip whitespaces, etc., in the workflow before pasting. I appreciate that you will say the problem is that you may not know the position on the clipboard of the item you need but I thought it worth pointing to the help page nevertheless. Stephen Link to comment Share on other sites More sharing options...
sepulchra Posted October 14, 2023 Share Posted October 14, 2023 17 minutes ago, olfway said: Thanks for your suggestions! If I understand correctly then I have two options with workflows – run workflow for copy to clipboard or run workflow to paste, right? If I would run workflow to paste then I'll miss alfred's clipboard history viewer, so that's not an option So it seems the only way I can use it – create a workflow to get current selection, strip whitespaces from it and paste it to clipboard and assign it to cmd+c hotkey But there will be a problems here – sometimes I want to copy images or files and sometimes I copy via menu instead of hotkey and sometimes iTerm itself copies selection to clipboard Probably if Alfred would have a trigger like "text content copied to clipboard" and output like "replace content in clipboard history" then I would be able to make a workflow which would work. But actually I think that whitespace trimming is so basic feature, so it could be added as a feature to alfred's clipboard manager itself Unless I am misunderstanding something these actions should still be in your clipboard unless you check "mark transient in clipboard" in the "copy to clipboard" object. if you copy or paste in frontmost app they should still stay in your clipboard after you paste. In my screenshot below, my actions for Reverse Line Order and Shell Escape Text both remain in the clipboard after pasting in the front most app. Link to comment Share on other sites More sharing options...
sepulchra Posted October 14, 2023 Share Posted October 14, 2023 or if you are looking to transform something already in your clipboard list you can make the workflows as universal actions like I have in my previous post and take action on what you want directly from your clipboard history. Does that solve your use case? Link to comment Share on other sites More sharing options...
olfway Posted October 14, 2023 Author Share Posted October 14, 2023 If I understand correctly – I could create an universal action like "Paste with stripped whitespaces" and then select it from history viewer or run it with some special hotkey, right? That's probably would work but that's too many actions for this task, I just want to press cmd+c, cmd+v or select from history viewer and always have it pasted with stripped whitespaces For other text manipulation like lowercase, UPPERCASE and so on it's really useful I will certainly use it, thanks! Link to comment Share on other sites More sharing options...
vitor Posted October 14, 2023 Share Posted October 14, 2023 36 minutes ago, olfway said: and assign it to cmd+c hotkey Don’t do that (also, Alfred won’t let you) because Alfred relies on it to copy (there’s no universal way to copy something from every app, so that’s the way it needs to happen). Taking from the excellent suggestions by @sepulchra and @Stephen_C, you can have a Hotkey Trigger with macOS Clipboard Contents and Transform it to trim it. By adding an Arg and Vars Utility with a {clipboard:N} dynamic placeholder you can even directly paste a specific entry. With a Universal Action you can do it from the Clipboard History. What you can also do is have a Hotkey Trigger with Selection in macOS connected to the Transform, connected to the Copy to Clipboard Output. That way when you’re looking at the item in Clipboard History, you press the new shortcut and have it paste trimmed. And with that and the first Hotkey, you have both situations covered with one Hotkey each (instead of ⌘V). There’s also a Trim Line Whitespace Automation Task which can trim from every line (as the title says instead of just from the whole text. Some times that’s what you want, sometimes, not, there are many options! sepulchra and Stephen_C 2 Link to comment Share on other sites More sharing options...
sepulchra Posted October 15, 2023 Share Posted October 15, 2023 Well that is a nifty trick! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now