Jump to content

jslr

Member
  • Posts

    7
  • Joined

  • Last visited

jslr's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. This is great. I know— my hack of Shawn's workflow was still unfinished. I had an add action that ran off a separate hotkey, and another one that wasn't wired in yet. Your demo gives me a lot to learn from. Thank you! Now, must get my head around Python...
  2. Workflow here, if you have a minute to take a look: Text tag workflow. It's based on something Shawn Rice originally put together for urls.
  3. Thanks! This makes a lot of sense, and I've got a piece of script ready to go with the appropriate conditional switch, but my problem is that if the input doesn't match anything in the filter list, Alfred won't do anything. Pressing enter has no effect, so I don't know how to manipulate call upon that input with the script. Feels like I'm close... Is there a setting in the first script filter itself that I could be overlooking?
  4. Ah. Thanks for setting me straight there. I was thrown because the script filter seems to stop dead when the input is beyond the scope of the filter's results... My script filter is currently connected to two actions. On enter, the result is passed to a "copy to clipboard action". On enter+cmd, the result is passed on to a "run script" action that deletes the selected item from the json file that powers the filter. Apologies for any lack of clarity— first time trying to author my own workflow. The intended workflow: hotkey(cmd+shift+2): call Alfred and display list of text items from json file for selection - press enter: paste selected text item to frontmost app -- if input doesn't match anything in the filter, add input to json that powers the script filter AND paste to frontmost app [this is what I'm trying to work out] - press cmd+enter: delete selected item from the json that powers the script filter
  5. I'm trying to figure out how to trigger an action from a script filter in the event that there's no match. I've hacked together a workflow (hotkey: cmd+shift+2 --> script filter) that allows me to manage text keywords/tags, and I'm trying to refine it further. Currently, the script filter I've cobbled together selects existing keywords/tags from a json file and pastes them wherever the cursor is placed or, if an action modifier is invoked at point of selection, deletes the selected keyword from the json file. I've already figured out a separate workflow that can allows me to add a keyword to the json file, but I'd like to everything to be triggered by the same hotkey. Any pointers? Thanks in advance for any help!
  6. Okay. Figured out my own solution yesterday, using a a keyword trigger ("+@") for a "run script" action containing the following: $name = trim("{query}"); $tag = "@".$name; $file = file_get_contents('path-to-tags.json file', true); $data = json_decode($file,true); unset($file); $data[] = array('name' => $name, 'tag' => $tag); $result=json_encode($data); file_put_contents('path-to-tags.json file', $result); unset($result); When I invoke Alfred, "@" pulls up a list of tags I've already pushed to the json file. If the tag doesn't already exist, I can cursor back to the beginning of the line and simply insert "+" to add it to the list. I use this mostly in nvALT. It's better than text expansion because I don't have to remember exactly what the keywords are, thanks to filtering/auto-completion. While nvALT offers its own tagging system, tag keywords in text allow for compatibility with other text editors (for example, when I'm working on the same text files via iOS). Currently works like a dream. Probably wouldn't have arrived at this point without your solution as a starting point— apologies for hijacking the thread, but thanks so much for the solution.
  7. Hey @rice.shawn - thanks for this! I just hacked it a little to serve as a way of maintaining a simple system of text keywords/tags that I can paste into documents whenever needed. It fixes something I've been trying to get my head around for ages— a way to insert tags into text documents in a way that will also work on an iOS device (i.e. not OpenMeta, not app dependent, just plain text keywords in the body of the document). I'm wondering how difficult it would be to script a function that would allow someone to add keywords to the json file on the fly? I've managed to get as far as adding a "write_tag.php" file that contains the following: <?php require_once( __DIR__ . '/Alphred.phar' ); if ( isset( $argv[1] ) ) { $tags = json_decode( file_get_contents( __DIR__ . '/tags.json' ), true ); } $tags[] = array('name'=>trim( $argv[1] ), 'tag'=>'@'.trim( $argv[1] )); $json = json_encode($tags); echo "$json"; I set this up through a keyword input to run script. I've figured out how to read the JSON, and I've almost figured out how to add an entry to the array, but I'm not getting the correct output, and I've yet to figure out how to write to the file. It's been a while since I've scripted anything with php, and this is my first time playing with an Alfred workflow. Thanks for any pointers...
×
×
  • Create New...