How can I create URL shortcuts/redirects for task/diff IDs in Phabricator?

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.

ua741

Posted 2019-03-18T06:20:57.860

Reputation: 163

Answers

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.

sachinjain024

Posted 2019-03-18T06:20:57.860

Reputation: 333

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

– sachinjain024 – 2019-03-18T06:51:14.400

1This 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<numbers>?) – user1686 – 2019-03-18T06:52:51.513

2@grawity It can only trigger when search?q=T<numbers>. 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. – sachinjain024 – 2019-03-18T06:58:20.843

This looks good. How can I modify the regex so that it does not redirect for T12312 some text? – ua741 – 2019-03-18T08:00:46.937

3You 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 – 2019-03-18T09:49:05.790

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<number><period> in your query so not to have a conflict with other queries if that's the case

– sachinjain024 – 2019-03-18T11:10:06.983

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.

user1686

Posted 2019-03-18T06:20:57.860

Reputation: 283 655

1Thanks, @grawity for sharing this! This is really handy. – sachinjain024 – 2019-03-18T06:37:49.027

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 – 2019-03-18T07:52:24.683

5Then I would create a keyword for the whole Phabricator instance – typing phab <Space> <Ctrl+V> or p <Space> <Ctrl+V> might be faster than manually editing T123 to T 123. – user1686 – 2019-03-18T07:55:58.747