Jump to content

vitor

Staff
  • Posts

    8,525
  • Joined

  • Last visited

  • Days Won

    712

Posts posted by vitor

  1. in="{query}"
    
    blah='	' read -a array <<< "$in"
    
    echo "${array[0]}" > output.txt
    echo "${array[1]}" >> output.txt
    
     

    Multiple files are tab separated. Code above reads the {query} input, splits on a tab and stores it into an array called "array". Items can then be individually accessed or you can run them through a loop. Looping through would look like this:

    for fn in "${array[@]}"
    do
    	echo "$fn" >> output.txt
    done
    

    Hi, thanks Alfred team for the great tool.

     

    How to handle multiple files, when some file names includes spaces?

     

    this code

     

    blah='    ' read -a array <<< "$in"

     

     

    splits file name with spaces into several array elements.

     

    Regards

     

     

    The code for separating the files’ names can be greatly simplified (no need for the array), by doing simply

    echo "{query}" | perl -pe 's/\t/\n/g' > file_list.txt

    That’ll take the tabs and convert them to newlines, achieving the same with less code, making it more easily reusable and maintainable.

  2. For those of you that modified this to download the audio, you should check the instructions again. They’re now not only shorter, you also don’t need to open a terminal for the code to run (that is, I’d say, a significant improvement). You don’t have to repeat the lengthier steps (installing XCode’s CLI tools, homebrew and ffmpeg), naturally, but I think the other ones are worth redoing (i.e., start on step 6). I’d also recommend you download the workflow again and work from there, as the changes are now so minimal, it’ll be less work than trying to work backwards from the current configuration.

  3. It’s not a space, it’s a newline. You’re outputting it when you use python’s print, and it’s then being read by the bash command.

     

    You can pretty much replace the python and bash modules with a single bash module containing

    search=$(echo "{query}" | sed 's/ /-/g')
    open "http://giphy.com/tags/${search}"
    
    That’ll do the same thing (without the extra stuff at the end of the url), with less code.
  4. Suggestion : If it could also display the default keyboard shortcuts along with the menu item.

    See two comments above yours.

     

    The shortcut keys can't be reliably extracted, hence the lack of display. The applications that display shortcut keys for applications exhibit similar problems, which is why at least one of them let you download custom shortcut lists. I believe the shortcut extraction can be improved slightly based on the results from the proprietary apps but I'm not sure how they're doing it.

  5. Yes, what you’re looking for is the “Script Filter” option on workflows. When making a new workflow you have a “Script Filter XML Format” under “Examples”. You can take a look at that, and there are a lot of workflows on the forum that use them (there are even workflow handlers in various languages that’ll make that work easier for you).

     

    If you have any trouble implementing that, feel free to ask — people on the forums are usually very helpful.

  6. Hi Victor,

     

    The hotkey / combo still works, it's simply displaying differently in Alfred. If I setup a cmd+shift+4 hotkey, it works as expected when I use it.

     

    Cheers,

    Andrew

     

    It is, you’re right. For some reason it seems to be taking a bit to act on it (may very well be the scripts fault), which explains why it seemed to not be working before.

     

    Thank you.

  7. Setting a combo to shift + a number and expecting the number is an impossibility as OS X and Alfred will always recognise the modified key instead (e.g. the $ sign, not the number 4).

     

    I have to disagree there, at least in what concerns OSX. If I go to System Preferences → Keyboard → Keyboard Shortcuts, and set a shortcut there, OSX can do it correctly without a problem. So if you tell me a third-party app couldn’t for some reason implement this without some work, I’d accept that, but it is clearly not an impossibility on OSX.

  8. I have a portuguese keyboard. This means that I type 4 using a single key, and $ by issuing ⇧+4. The problem arises when I try to set a keyboard shortcut (happens both in workflows and with Alfred’s main hotkey) to ^+⇧+4 — Alfred sees it as ^+⇧+$, which means it’s expecting me to use plus a key that already needs it in the first place, effectively preventing the correct usage of the shortcut.

  9. You don’t add every directory by hand, you pick the common parent directory and add that one.

     

    Seeing as you’re clearly a homebrew user, the question is “do you need this to work for some other reason, or are you only concerned with homebrew apps?”. If the latter, I’d suggest a look at homebrew-cask (linked on my previous post). It works in conjunction with homebrew, and is more geared towards this type of actions (as I’ve mentioned, there’s even a command concerned with helping Alfred find the apps).

  10. Okay, thanks for the answer

     

    However, in this case it is not directly the utility I use, but rather an utility (ffmpeg) used by the utility (youtube-dl) I use. Is there a way to load the user's default $PATH variable when launching Alfred script? (it seems that the PATH must not be the correct one since it had not found `ffmpeg` :)

     

    Well, yes and no. The problem is that it depends, and there is no one solution. For example, if you’ve set your PATH in your ~/.bashrc file, you can easily put something like

    source "${HOME}/.bashrc"
    

    on top of the workflow’s code, and it’ll get it (along with everything else). But what if the user did it in ~/.bash_profile, or uses another shell, like zsh? That’s why you can’t really (easily) cover every case, but can make it fit your needs with a simple tweak.

  11. it worked, I feel like crying with joy. Thank you, thank you, thank you.

     

    I also got it to work just extracting the audio only, today is a great day. One question though, how come the workflow makes an alert sound in terminal?

     

    Good news. Glad to know it’s working.

     

    The alert sound goes off so much for so many reasons that I’m not even sure what it could be finding here (since the workflow “types” everything in the terminal, it’s probably a reaction to that). If you want to disable the sound (for everything in the terminal), go to Terminal → Preferences… → Settings → Advanced, and turn off Audible Bell. I’m definitely a bigger fan of Visual Bell, way less annoying.

  12. Well, i did it all over again and tried the last step in terminal and alfred. I actually did number 6 wrong and wasn't copying the run script into the terminal command. So i remedied that and still nothing.

     

    Alright, tested and working, here’s the workflow (version to keep both audio and video). The link expires in about two weeks.

    If that still does not work for you, then it means one of the other steps is the problem, in which case please give me the output of

    brew list
  13. This is a great workflow, I was wondering though: is there a way to download only the audio from youtube, without first downloading the whole video & then discarding it?

    There is not. This is due to the fact that youtube is not keeping an audio version you can download, so you have to download the video and extract it from there.

     

    Yeah i felt like i did something wrong on the workflow bit.

    From your screenshots, I see that you’re using the latest version, and that you’re also using WatchList, so I don’t want to break that functionality. I’ve updated the old post, so you can follow those instructions (the lengthy part you’ve probably already done). Following that, it should work how you want, please tell me how it goes.

    You can also run

    sudo rm "/usr/bin/youtube-dl"
    Since you’ll be installing it another (better) way.
  14. So i followed the steps and i am having trouble. Basically, i tried doing the last step in terminal and Alfred and i just get an error saying "unknown url type".

     

    That seems like an issue with the modifications to the workflow. Since that post is a bit old already (in the sense that the workflow has already suffered multiple modifications), may I take a look at yours, to try to diagnose the issue you’re having?

  15. While Vitor's solution can work in some cases, the more reliable way is to add the path of the apps you want to include into the Search Scope box in the Default Results preferences. :)

    I thought about that, but the question is very specific to links, not apps. Since ~/Applications is mentioned, it seems like the poster may have different apps at different locations (maybe by using different package managers that install to different places, like homebrew and homebrew-cask), that all link to that same directory. In this case, my solution will be less work overall, as you only need to perform it once, while adding the path of the apps may or may not take multiple edits, everytime you add/remove one of the locations. I’d argue, then, that in this specific case the solution would work in more cases and with less work, by taking into account the specificity of the question.

     

    Details to the “why”, however, could of course be useful, as there may even be alternative solutions. Homebrew-cask, for example, includes a “brew cask alfred” command that programatically changes Alfred’s scope to include the app directory.

×
×
  • Create New...