0

Is it possible to write an AppleScript or macOS service/daemon to detect when a URL is clicked (which would launch the browser) and run a bash script as well/instead? Use case: detect when github.com links are clicked and run a bash script that opens the PR in gh.nvim (if it's not a PR or one I care about it would exit out and continue in browser). For clarification - I'm happy writing the bash script and probably happy writing whatever script will pick up the URL click. Just need some pointers on if this is possible and how it'd be done. Thanks.

7
  • Intercepting data detectors or URL loading is likely to be fraught with security hurdles, for obvious reasons.
    – benwiggy
    Commented Apr 3, 2023 at 9:56
  • yeah that's what I thought, but figured I'd ask anyway. I'm trying to adopt gh.nvim into my workflow but struggling because when a co-worker messages me with a PR to review it just launches github.com and it's easier to review there than go back to alacritty and launch it in gh.nvim.
    – Tom Oakley
    Commented Apr 3, 2023 at 10:43
  • Aren't you rather for a link redirection service?
    – nohillside
    Commented Apr 3, 2023 at 11:06
  • I don't think so. I want URLs which start with github.com (might refine later to e.g github.com/org/repo) to run a custom bash script which will switch window focus to Alacritty (terminal emulator) and run a script which will run Neovim and run the custom gh.nvim command to open the pull request in neovim. Fully understand why this might not be possible due to security limitations. But wanted to double check. Basically: custom Universal Links for macOS which I can define myself.
    – Tom Oakley
    Commented Apr 3, 2023 at 11:34
  • I guess in theory a link redirection might work (redirect github.com to myapp.com, create small macOS app that uses Universal Links correctly and securely launch my app, pick up URL, get back original github URL and run my bash script). But I was hoping it'd be simpler than that; perhaps that's what I need to do though.
    – Tom Oakley
    Commented Apr 3, 2023 at 11:39

0

You must log in to answer this question.

Browse other questions tagged .