alfred-workflows
alfred-workflows copied to clipboard
Support multi term queries (instead of full substring)
Would send a pull request but the source files are not checked in directly so I'll post the change to chrome.php here directly.
Inside the if($query !== '')
Change
if (strpos(strtolower($website['title']), strtolower($query)) === false && strpos(strtolower($website['url']), strtolower($query)) === false)
{
$use_result = false;
}
for
$terms = split(" +", $query);
foreach ($terms as $term)
{
if (strpos(strtolower($website['title']), strtolower($term)) === false && strpos(strtolower($website['url']), strtolower($term)) === false)
{
$use_result = false;
}
}
This will allow matching each term to different parts of both the title and url. This is useful when you only remember parts of the title or want to match a part of the url and a part of the title. A common case is when looking for a Google Docs file, by typing "ch docs keyword" (it can match docs to the url and keyword to the title).
This is brilliant. Thanks.
:) you're welcome
btw, another thing that happened to me when using this workflow is that I have 2 Chrome profiles (personal and work) and the sqlite.php automatically copies the history db from the "Default" profile. What I did was duplicate the workflow, change the trigger keyword for the copy and update the sqlite.php to point to the right "Profile X" folder.
I don't think it's worth doing much about it, although perhaps extracting the "Default" part of the path to a variable and adding a comment on the code would help future users to understand what to change and perhaps adding a note on the README about how to deal with non-default Chrome profiles.
Thanks again for a super useful workflow. I normally used the Chrome url bar to search the history but it's not very friendly with multi term searches so this saved me!