6

Is there a way to create Phabricator shortcuts? Like when I type T123 in the address bar, it should take me to https://secure.phabricator.com/T123. On the same note, I want shortcuts for Diffs and Pastes.

Here is a list of patterns I need a shortcuts to:

T - Any number
P - Any number
D - Any number

I don't mind using any browser trick or, in fact, using a Chrome extension to solve this for me. It would be a huge productivity boost.

PS: I primarily use Chrome so even a solution which is Chrome-specific should work for me.

Anaksunaman
  • 16,718
  • 4
  • 38
  • 45
ua741
  • 163
  • 5

2 Answers2

12

Built-in Chrome functionality only allows shortcuts which start with a space-separated "keyword", e.g. T 123. Right-click the address bar, select "Edit search engines", and add several new search engines like this:

  • Keyword: T
  • URL: https://secure.phabricator.com/T%s

The same feature is available in Firefox. While it doesn't have a convenient way to add custom search engines, you can instead create a bookmark with the same URL (same %s syntax) and assign a keyword to it through the bookmark's "Properties" window.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • 1
    Thanks, @grawity for sharing this! This is really handy. – Sachin Jain Mar 18 '19 at 06:37
  • Thanks for sharing this trick, upvoted. Usually the diffIDs or taskIDs are shared in this format T{id}, D{id} (without space), so I would just want to paste the ID and press enter. – ua741 Mar 18 '19 at 07:52
  • 5
    Then I would create a keyword for the whole Phabricator instance – typing `phab ` or `p ` might be faster than manually editing `T123` to `T 123`. – u1686_grawity Mar 18 '19 at 07:55
6

You can use Requestly chrome+firefox extension to setup URL shortcuts.

Here is an old article which explains how to setup URL shortcuts for JIRA projects. You can set up a similar Redirect Rule in Requestly to achieve this use case.

Follow these steps

  1. Install Requestly, if not already installed
  2. Create new Redirect Rule
  3. Define Source & Destination as

    Request URL -> Matches (Regex) -> /search\?q=T([0-9]+)/ig
    Destination https://secure.phabricator.com/T$1
    

Explanation

  1. Use Regex match to identify the Task/Diff/Paste number from Google Search Query
  2. Redirect to corresponding Phabricator URL using matched value

You can also use this - https://app.requestly.in/rules/#sharedList/1552883742989 to directly get above rule. You must have Requestly installed to import the rule.

Here is a screenshot for setting up the rule:-

enter image description here

PS: I built Requestly.

Sachin Jain
  • 431
  • 3
  • 15
  • I just wrote an article covering this question & answer on Requestly's official medium channel to benefit the community - https://medium.com/@requestly_ext/phabricator-productivity-tips-3f38418f9510?source=friends_link&sk=5a48e538e036eebfb317b15cfdbb473c – Sachin Jain Mar 18 '19 at 06:51
  • 1
    This should probably match a larger part of the URL (at least including `google.com` or OP's other default search engine), otherwise it may trigger on searches on quite a few websites which use `/search?q=`... (For that matter, it'll probably trigger on regular attempts to google `T`?) – u1686_grawity Mar 18 '19 at 06:52
  • 2
    @grawity It can only trigger when search?q=T. What I have is an idea and I hope OP can customize it according to his/her needs. Depending upon the situation, we can write more constrained regex but I leave that to the OP and others using the rule. – Sachin Jain Mar 18 '19 at 06:58
  • This looks good. How can I modify the regex so that it does not redirect for `T12312 some text`? – ua741 Mar 18 '19 at 08:00
  • 3
    You can just add `$` to the end (or `[$&]` if you also want to catch the case of possible additional search parameters). There are some really good online regex testers out there, with which you can easily edit and test your regex in realtime :-) – Falco Mar 18 '19 at 09:49
  • I have been using the JIRA shortcut as explained in https://medium.com/@requestly_ext/create-url-shortcuts-for-jira-projects-4fd49abdcae7 and never faced any issue. You could try something similar and modify your regex. For example - You can say T in your query so not to have a conflict with other queries if that's the case – Sachin Jain Mar 18 '19 at 11:10