isometry Posted March 18, 2013 Share Posted March 18, 2013 (edited) A deceptively simple workflow to process the contents of the clipboard through your one-liner of choice. Behind the scenes this is just running pbpaste | {query} | pbcopy, so its power is limited only by your skill at the command line and imagination Download / Source Note: Alfred 2 currently strips hotkey settings for safety, so if you want to initiate the prompt by hotkey for extra ninja-fu, you'll need to set your own. I personally favour Cmd+Shift+| Robin Edited March 21, 2013 by isometry Link to comment
isometry Posted March 20, 2013 Author Share Posted March 20, 2013 Added a Hotkey object to the start of the workflow: once defined, you can save a few keystrokes. Copy the text you want to process, hit your hotkey, enter your one-liner and paste the results. Link to comment
isometry Posted March 21, 2013 Author Share Posted March 21, 2013 (edited) Added support for command aliasing: alias commonly used one-liners to one-word aliases. | alias myalias=arbitrarily -complex | pipeline@@ | myalias | alias lc perl -nle 'print lc'@@ | lc Edited March 21, 2013 by isometry Link to comment
isometry Posted March 21, 2013 Author Share Posted March 21, 2013 Not sure people are feeling the love for this one so I've added some built-in one-liners to try and illustrate its power. I've used it at least 5 times today already. Examples include: filtering the contents of the clipboard with grep modifying the contents of the clipboard with sed, awk or perl base64 encoding/decoding the clipboard encrypting/decrypting the clipboard with AES-256 sorting the clipboard reversing the lines in the clipboard strip blank lines from the clipboard upper/lowercasing the clipboard add line numbers to the clipboard full listing of the built-ins macosxguru 1 Link to comment
ctwise Posted March 22, 2013 Share Posted March 22, 2013 (edited) Added a Hotkey object to the start of the workflow: once defined, you can save a few keystrokes. Copy the text you want to process, hit your hotkey, enter your one-liner and paste the results. Very, very nice workflow. If you change the hotkey to 'Selection in OS/X', it will auto-copy the selected text to the clipboard for you. Then you can connect the hotkey to a one-line bash script that does this: osascript -e 'tell application "Alfred 2" to search "| "' Then the hotkey copies the selected text and triggers the workflow in one step. You can also take the 'pbcopy' out of the zsh script and put the 'Copy to Clipboard' step at the end. Then you can check the box 'Automatically paste to front most app'. Now, when you select text, trigger the hotkey and select a filter, the result will replace the selected text. In addition, the list of items is clearer (at least to me) when the description is the title and the command-line is the subtitle. So, with a few formatting changes, it looks like this: title: Encode base64 (builtin) subtitle: openssl base64 -e Edited March 22, 2013 by ctwise Link to comment
isometry Posted March 22, 2013 Author Share Posted March 22, 2013 @ctwise: excellent tips regards Selection in OS X and Automatically paste to front most app - thank you! I'll think about how best to integrate them into the release in such a way that (ideally) both behaviours are available. What you suggest is actually what I originally had in mind, though it doesn't necessarily fit well with, for example, selecting text from a terminal window. Regards the format of feedback, I did try it that way around, but because you can (and should!) define your own aliases, which (currently) lack descriptions, it didn't make sense to do so. I could change the syntax, of course: | define description==pipeline@@. What do you think? Link to comment
judas Posted July 21, 2013 Share Posted July 21, 2013 This looks powerful, but I have no idea what to do after I installed it! :-) Link to comment
politicus Posted October 17, 2013 Share Posted October 17, 2013 Hey ismoetry, I installed your workflow and find it very useful. Thank you. I do not know shell scripting enough to solve the problem I have, copy i.e. 4 lines get them clipped as 4 different clips not just one paragraph. Do you think your workflow can help me? (Red the readme file, think your workflow is more about filtering what is already clipped). If not, consider my question as a feature request My question on Alfred help forum: http://goo.gl/NLnMFH Link to comment
rossbennett Posted March 2, 2014 Share Posted March 2, 2014 This is brilliant for more than one reason. I'm going to get loads of use out of this. And it looks like I'm going to get a whole new perspective on scripting, too. Thanks very much! Link to comment
manishie Posted November 15, 2014 Share Posted November 15, 2014 woohoo, this workflow is awesome! thx. Link to comment
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