Jump to content

Matthew Lancellotti

Member
  • Posts

    15
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Matthew Lancellotti

  1. This is a cool workflow.  Seems to work on High Sierra with the exception of opening the newly made file in your favorite application.  I have notifications disabled so I don't know if that part works.

     

    I'm wondering if we could somehow eliminate the redundancy in the workflow where it has a separate row for each filetype.  Do you think it's doable?  It would be nice to have a big folder of template files and have the workflow access all of them.  Thoughts?

  2. Really great script!

    How can I modify the script so that it works on the selected text in whatever app I have open?

     

    @johnjoonso: Sorry I haven't checked this thread in so long.  You must COPY the text to your clipboard (typically via Edit > Copy or ⌘C) before running the workflow.

     

    Then, when you type your regex and hit enter, the result is automatically pasted.

     

    ------

     

    As a bonus, this means you could potentially copy text from one location, then move your cursor to another location, and get the result in the new location.

  3. Currently there are some issues with Run Script when using /usr/bin/php, /usr/bin/perl, /usr/bin/python, etc...

     

    Those processes are launched from the shell using certain environment variables (such as LANG=C or another non-unicode supporting environment) which disable features or environments we may need to run our scripts correctly.

     

    Currently the only solution to this would be to use /bin/bash or /bin/zsh and set things ourselves and then launch our script from there.  Doing so means we sacrifice the convenience of having scripts right in the workflow visual themselves AND we can no longer take in the query conveniently.  We must now take in the query through bash for example, which is quite tricky (an experienced programmer may be ok, but just try taking in something like She said, "He said, 'this is fantastic!' ", and you'll see things are much worse than what is apparent).

     

     

     

     

    To save us from this mess, we could have a vertical dual pane Run Script, where the top pane is a bash or zsh, and the bottom one of the script languages.  Users can then easily set any setup variables they need to make things run smoothly.  :)

     

    Thanks kindly,

    Matthew

  4. Thanks for all the useful info, deanishe!

     

    I found a simple solution, and it was to change the environment variable from within my script.  This is good because I don't have to take my query in through bash, and it will work wherever I distribute my workflow.

     

    In Perl specifically, I used $ENV{LANG} = 'en_US.UTF-8'; at the beginning of my script.

     

    My only question is, will non-US users have the en_US.UTF-8 environment?

  5. Unfortunately, outputting in UTF-8 is not working.  The ⌂ character, which I copied from a website (HTML code ), still causes question markiness.

     

    The â character, on the other hand, causes the Alfred error:

    [ERROR: alfred.workflow.action.script] Code 0: Wide character in print at VeryKiwiFilter.pm line 56.

    My workflow grabs things from the clipboard, so I don't know how the input is coded.  Will the clipboard guarantee it is UTF-8?  Can the input be encoded in many different ways depending on what was copied?

     

    But either way, the output still looks great in the terminal, but not in Alfred.  How can I further troubleshoot?

  6. My workflow script ends with printing output.  That output goes to Alfred's "copy to clipboard".

     

     

     

    1. How does Alfred interpret the output it receives?  Do I need to escape anything in my output?

     

    Perl code:

    print 'this is a string with special characters in it Đ⌂'
    

    The above is a simplified model.  What is REALLY happening is the Perl code copies the special characters from the clipboard in the first place, then prints them out.  When I look at what the Perl code prints out in the terminal, I can see the special characters just fine.  So it seems that it is ALFRED who is unable to accept the special characters or put them into the pasteboard correctly.  It replaces them with '?' question marks.

     

     

     

    2. I am open to creative solutions.  I never intended to copy my output to the clipboard in the first place.  I just needed to use the "paste into frontmost application" option.  Using an apple script to execute "cmd-V" is an option, but I don't think it will work in all applications.  I guess my second, slightly related question is "How does Alfred paste into the frontmost application reliably?"  Maybe I can mimic that behavior and bypass Alfred.

  7. Dave,

     

    Thanks for the great workflow.

     

    1. When I type "weather", I see an "Hourly Forecast" and an "Hourly Forecast at ..." option.  Are those default Alfred things?  I can't seem to find where they are coming from.  How can I disable those?

     

    2. Feature request: Would you be able to get the hourly forecast in the same way you get the 4-day forecast?  I usually need to see the hourly.

  8. Version 1.5.0 is here.  Here are the improvements:

     

     

    A checkmark appears on the icon when your regex is valid (correct syntax). Regex will not execute invalid regexs. It is…awesome.

     

    You have full control to do custom regexing by opening the file at ~/Library/Application Support/Alfred 2/Workflow Data/com.verykiwi.com/RegexSequences.pl. Your custom regexs remain even when updating Regex.

    Quoted regexs (sq) can be saved.

  9. Perform a search and replace on copied text, and save regexs for future use.

     

    Download:


     

    Please visit http://code.instructorium.com/regex for more information.  (also on Packal: http://www.packal.org/workflow/regex )  A summary is below:

     

     

     

    Commands you can use:

     

    1. Any regular expression (no keyword necessary, Perl-style) "s/this/that/msg" "s@\$(\d+)\.(\d{2})@$1 dollars and $2 cents@g", etc.

     

    regex1.png

     

    2. Follow your regular expression with " save as " and then a name in order to save it for future use. "s&this&that&xg save as mythisthat", etc.

     

    regex4.png

     

    3. Use the "regex" keyword followed by the name you saved it under to execute a saved regex. "regex mythisthat", etc.

     

    regex3.png

     

    As far as I know, it works on all versions of Alfred 2 and all versions of OS X.  Your custom workflows are saved under ~/Library/Application Support/Alfred 2/workflows/com.verykiwi.regex/RegexSequences.pl.  You can delete the com.verykiwi.regex folder after uninstall.  Feel free to contact me if you have any issues.

  10. I am about to release my workflow, http://www.alfredforum.com/topic/5100-regex-run-and-save-regular-expressions/ , onto Packal.

     

    The workflow contains a file that contains user data.  That is, users can save their own regexs for future use, and those saved regexs are saved in the file.  Let's call it MyRegexFile.pl.

     

    When I release the next version of my workflow, how can I make it so that user data is not overwritten?

     

      * Perhaps there is a special Alfred way to handle updates

      * Perhaps there is a special Packal way to handle updates

      * Perhaps the file should be stored elsewhere on the user's computer

      * Perhaps the file contents should be stored in the keyword script filter itself

     

    Those are my ideas.  I would like to find the right solution before releasing the new version.  I would like the solution to be user friendly.

     

    Thanks!

×
×
  • Create New...