stephenmcleod Posted October 21, 2014 Share Posted October 21, 2014 (edited) Edit 1: I had compiled a workflow to encrypt/decrypt text using the keybase.io shell, through the terminal. I noticed a fatal and rather glaring error, so have removed it for now. I need to look closer at parsing {query} into two parts, so will revisit this later on. --- Edit 2: Have come up with an alternative method to get it to work, taking inspiration from David Ferguson's Script Filter examples. -- What it does: * Takes text, encrypts and signs it using the Keybase shell, using the public key of another keybase.io member that you specify in a second Alfred prompt - copying the resulting PGP block to the clipboard. * Decrypts messages received from other keybase.io users * Allows you to quickly track other keybase.io members from the Alfred search bar, rather than having to fire up Terminal and input the command manually Limitations: * This is really for people who are exchanging messages with the same people regularly. It doesn't handle the first interactions between users that don't already track each other very well due to the verification process. Something that I'll look to improve in future. -- Download and Contribute Please check it out and give feedback/bug reports/glaring errors and flaws that you spot that I've missed, etc. GitHub repo is here. Edited October 22, 2014 by stephenmcleod Link to comment
vitor Posted October 21, 2014 Share Posted October 21, 2014 (edited) Which language? In bash, it can be as easy as (assuming you’re using a comma to separate the fields): IFS=',' read first_field second_field <<< "{query}" In that case, if your query is, say this is a text,this is another, you’ll be left with a ${first_field} variable populated with this is a text, and a ${second_field} variable populated with this is another. Turn on escaping of Backquotes, Double Quotes, Backslashes, and Dollars, in Alfred. Edited October 21, 2014 by Vítor Link to comment
stephenmcleod Posted October 21, 2014 Author Share Posted October 21, 2014 Hey! After fiddling about for ages, I've gotten the parsing to work in PHP with: $query = "{query}"; $run = explode("-", $query); echo "keybase encrypt " . $run[0] . " -m " . '"' . $run[1] . '"'; Using '-' as the separator for now to test things out. The echoed line is what needs to be passed through to the terminal to encrypt the text in $run[1] for the username specified at $run[0] I guess I hadn't really worked out how to pass the value from PHP to the terminal with the steps available in the workflows. Perhaps if I use Bash instead of PHP it would work better! I'm not a coder by any stretch of the imagination, so this is as much a learning process as anything else. Link to comment
stephenmcleod Posted October 22, 2014 Author Share Posted October 22, 2014 Found an alternative way to get it working, so updated the original post to reflect that. Thanks for the help Vítor! You can download it on GitHub here to test it out: https://github.com/clickysteve/Alfred-Workflows/tree/master/keybase.io%20alfred%20workflow 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