Alfred and JIRA

Do you know Alfred? It is a Mac OS app to replace Spotlight and enhance the functionality which Cmd + Space offers you.

I implemented/copied a couple of simple scripts in the past, one of it was a JIRA Script by Sal Ferrarello which helped me open JIRA tickets with the keyboard.

Today I got a list of tickets by my PM and I thought it should be possible to open more than one ticket, so I wanted to change the workflow, but I couldn’t find any kind of “loop” and before searching for a solution (that should be possible, shouldn’t it? I learned, that I could use PHP ? <3

PHP in Alfred

Find the option “Run script”, then you see this window. In the upper left you choose “php” and that’s it! You can use Ruby, Perl, Python or Bash if you prefer 🙂

Screenshot of the "Run script" dialog by Alfred. The choosen language is "(opt/homebrew/bin/php" with "input as {query}" in the second dropdown.
The line continues with "running instances Sequentially", then a text area with the script below is shown.
Under the area is Escaping:
Spaces, Backquotes, Brackets and Semicolons are not chosen, but Double Quotes, Backslashes and Dollars.

<?php
$query = '{query}';

$tickets = array_map('trim', explode(' ', str_replace("\n", ' ', trim($query))));

foreach ($tickets as $ticket) {
    $url = "https://winkelwagen.atlassian.net/browse/$ticket";

    exec("open $url");
}

Overall the workflow is simple:

Screenshot of the workflow Keyword is "j", then a transform "uppercase" node and the last node is RunScript

Leave a Reply