Jump to content

Gary King

Member
  • Posts

    108
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Gary King

  1. 7 minutes ago, deanishe said:

     

    Oh yeah, that would do it. You might want to consider using Alfred's (macOS's) built-in method for opening apps—or using env -i—so as not to inherit the workflow's environment.

     

    This is something that annoys me about macOS. I wish your entire user session were bootstrapped from a shell, like on Linux. Very annoying for developers.

    Is there any problems with having the Alfred env vars exist in my shell? Or it just leads to possible "confusion", such as if my script is trying to read an Alfred env var, then the value would possibly be incorrect? 

     

    The reason I open apps like Terminal via a workflow using system commands (os.system in Python) rather than Alfred's method, is because I usually also need to pass args to the commands. And depending on the keywords used, a different app would be opened, etc. 

  2. 1 hour ago, deanishe said:

     

    Then you’ve screwed up your shell environment. You should *not* be setting Alfred’s variables in your normal bash environment.

     

    Only if you need to run a workflow script that will otherwise fail outside of Alfred, i.e. you’re developing a workflow. For my part, I use the autoenv plugin for zsh to ensure such variables

    are only set when I’m in a workflow’s repo and are immediately unset when I leave that directory.

    I'm not sure how the Alfred env vars ended up in my Bash env. 

     

    I have a workflow called "Finder" on my Mac, which contains several File Filters that I use to look for specific file types in different folders. That's the one whose Alfred env vars appear in my Bash, such as "alfred_workflow_uid" and "alfred_workflow_name". "alfred_workflow_bundleid" is not set though. 

     

    I don't know where these vars are being set. I looked in the usual places like ~/.bash_profile, ~/.bashrc, etc. but couldn't find them.

     

    ---

     

    Upon further inspection, I think I know why the Alfred env vars appear in Bash. What happens is that I have an Alfred workflow that opens iTerm, and therefore when I open iTerm with this workflow, the env vars are set. If I open iTerm through the Dock, then no Alfred env vars are set. So it seems to simply be working normally.

  3. 19 hours ago, deanishe said:

     

    If you just need to check whether your script is running in Alfred or not, check for the existence of one of the environment variables Alfred sets, e.g. alfred_version. If it's set, your script is running in Alfred.

    Thanks, but this variable also exists when I run the script outside of Alfred. Looking at `env` in Bash, I actually have a ton of Alfred variables already set there.

     

    I found a few `alfred_` keys that exist only in the workflow though, so I'll use one of those other ones.

  4. On 4/14/2018 at 5:36 AM, deanishe said:

    Here you go. It doesn't do anything useful, but it should make clear how to connect multiple inputs and outputs to one File Filter.

     

    Thanks for the example workflow.

     

    I suppose it is not possible to have live updating results when using the File Filter this way? For instance, normally if you change your input keyword, then the results would change to use your new keyword. But with this workflow, you only get results once you submit your keyword to the File Filter.

  5. I have two File Filters that are similar. They each essentially return the same file types from the same folder, except for a few file type differences. One keyword is "p" and the other is "pr".

     

    If I type "pr test" then I have some results appear, as expected. if I delete the "r" from the keyword so that it appears as "p test", then no results appear. I have to modify the search, such as by simply adding a space somewhere, before results appear correctly for "p test".

  6. I have a File Filter to look for specific file types in a specific folder.

     

    If I create a new file in this folder that matches these requirements, then use the File Filter keyword to look for this new file, then the new file does not appear. I have to restart Alfred before the new file appears.

     

    Yet, I can find the file just fine immediately in Spotlight and Alfred's normal file search.

     

    What can I do so that I don't have to restart Alfred whenever I add a new file?

  7. I have several keywords for file filters, that lead to several outputs. The file filters are all actually the same; it's just the keywords and outputs that are different.

     

    Is it possible at all to share the same file filter among several keywords and outputs, so I don't duplicate the filter? Since if I ever need to change it, then I have to modify it for every occurrence, rather than just a single one, which would make it much easier.

  8. I'd like to create a Script Filter, where when the user selects an option, then the current Alfred keyword is replaced with a new one.

     

    So for instance, the user types in "test " (with a space at the end), and then the script shows the options dropdown, and the user picks one and hits Enter, then the keyword now shows "test one", and my script will then show a new set of options.

     

    How can I do this with Alfred? Is it possible to do by connecting one Script Filter to another?

     

    Thanks!

  9. Is it possible to have just one script in an Alfred workflow, as a Script Filter, then when the user chooses an option, it will pass it through the same script, and based on the argument, either show new results, or open a URL?

     

    So, the part I need help with is making it possible to infinitely pass the argument into the same script, without of course creating an infinite number of Script Filter objects in the workflow.

     

    This would easy if, say, I just needed the user to choose two options, then I'd just have two Script Filters, but that's not the case here.

     

    Thanks!

  10. On 2017-02-21 at 2:12 PM, vitor said:

     

    It should work the same for both methods. And for me it does.

     

    I have "Restore clipboard content" set to the default, which is checkmarked and at 0.5s. Yet the clipboard is never restored.

     

    I copy "test", paste it a few times in a text file to ensure it's in the clipboard. Then open Alfred and type "sn <keyword>" to paste one of my snippets. The snippet is pasted into the text file. Then I wait a few seconds. Then I paste the clipboard's contents, and it's the Alfred snippet, not what I had before.

  11. 21 hours ago, vitor said:

     

    You can’t. Alfred needs to copy them to be able to expand (paste) them. But you can restore your clipboard to what it was. Alfred Preferences → Features → Snippets → (small cog in top right) → Tweaking → Restore clipboard contents after.

     

    This seems to only work if I have also enabled the feature to automatically expand snippets. What about if I paste snippets using the "sn" keyword in Alfred?

  12. I use Firefox as my default browser. However, some websites I only want to open in Chrome, so I setup a keyword for them, which opens the URL in Chrome.

     

    When Chrome isn't running and I run the keyword, Chrome opens two windows. One window has the URL I want, and the other window is just a blank tab.

     

    Why does Alfred open two Chrome windows? Is there a way to prevent the blank window from opening?

×
×
  • Create New...