Bhishan Posted April 22, 2019 Share Posted April 22, 2019 (edited) It would be extremely useful if we can create snippets on-the-fly from the clipboard contents. For example: "snip tmp" will create a snippet called "u;tmp" from the clipboard content. So that when typing "u;tmp" will expand that snippet automatically. For only one snippet I can do this: =========================== Alt shift t ==> copy the clipboard to tmp.txt u;tmpp ==> autoexpand the text after reading from tmp.txt from that workflow directory. But, this works only for one snippet. It would be nicer if it can be done more dynamically. The suggestion is much appreciated. I have provided MWE in the github shared file: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/aa Clipboard Copy.alfredworkflow?raw=true Edited April 22, 2019 by Bhishan Link to comment
deanishe Posted April 22, 2019 Share Posted April 22, 2019 Why don't you use a Snippet Trigger to show a list of the clipboard contents you've saved? Link to comment
Bhishan Posted April 22, 2019 Author Share Posted April 22, 2019 (edited) Because, lets say i have a code snippet from pandas groupby in python: gp1 = => daily = flights.groupby(['year','month','day'],as_index=False) and another snippet as gp2 = => daily = flights.groupby(['year','month','day'],as_index=True) It would be easier to type u;gp1 and u;gp2 than go to clipobard manager and search for clipboard history. Edited April 22, 2019 by Bhishan Link to comment
deanishe Posted April 22, 2019 Share Posted April 22, 2019 I said Snippet Trigger, not Clipboard History. Link to comment
Bhishan Posted April 22, 2019 Author Share Posted April 22, 2019 **Update** I could not create Snippet triggers, but found alternative route using Alfred Keyword. "sni hello" will create "hello.txt" from the clipboard. "sno hello" will read that "hello.txt" and paste to the frontmost application. This works great, but I am only missing "u;hello" and "u;hi" etc where I can simply type, instead of hitting keys. Link to comment
Bhishan Posted April 22, 2019 Author Share Posted April 22, 2019 (edited) @deanishe I guess I got what you mean: workflow: Keyword sni ==> get argument name to "arg1" ==> Snippet and use "arg1" as trigger name. I will try this method. If I could not manage to get it done, will seek further suggestion. Edited April 22, 2019 by Bhishan Link to comment
deanishe Posted April 22, 2019 Share Posted April 22, 2019 (edited) No, that is not what I mean. I'm talking about Snippet Triggers. You have a single snippet keyword that activates a Script Filter. The Script Filter shows you a list of the texts you've saved. You choose one and it's inserted into the current application. Obviously, you also need to add a way to save/add texts to the workflow. Edited April 22, 2019 by deanishe Link to comment
Bhishan Posted April 22, 2019 Author Share Posted April 22, 2019 (edited) I tried this: try to create dynamic trigger from the alfred workflow but, it did not work: - snn hello ==> creates hello.txt and var:arg is set to "hello" - tried to use that varible to make trigger object, but failed. It creates hello.txt but u;hello does not work. Edited April 22, 2019 by Bhishan Link to comment
Bhishan Posted April 22, 2019 Author Share Posted April 22, 2019 @deanishe Where are the snippets stored? May be If I create a directory "TemporarySnippets" in that folder and create a text file/json file/ whatever and call the snippet trigger afterwards? Link to comment
deanishe Posted April 22, 2019 Share Posted April 22, 2019 A dynamic trigger won't work for a Snippet Trigger because the variable arg will only exist when you run the workflow via the snn keyword. If you want any further help, please upload the workflow somewhere and post a link. Screenshots are not much use. Link to comment
Bhishan Posted April 22, 2019 Author Share Posted April 22, 2019 @deanishe I have uploaded the workflow here: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/aa Clipboard to Snippet - COPY.alfredworkflow?raw=true I am looking a way to create dynamic trigger using argument from the alfred workflow. Link to comment
deanishe Posted April 22, 2019 Share Posted April 22, 2019 25 minutes ago, Bhishan said: I am looking a way to create dynamic trigger using argument from the alfred workflow. Then your workflow needs to manipulate its own info.plist or a snippet collection. Auto-generating a snippet collection is probably the simplest way. 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