Clickable error numbers in alacritty

For people using alacritty and using GHC version 9.6 or higher, but lower than 9.10 here is a script that makes the GHC error numbers in compiler errors clickable. GHC 9.10 uses terminal escape codes to make them clickable so this script is not needed for that version.

open-ghc-error.sh

#!/usr/bin/env bash
xdg-open "https://errors.haskell.org/messages/$1"

alacritty.toml

[hints]
  [[hints.enabled]]
  command = "xdg-open"
  hyperlinks = true
  post_processing = true
  persist = false
  mouse.enabled = true
  binding = { key = "O", mods = "Control|Shift" }
  regex = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)[^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩`]+"

  [[hints.enabled]]
  command = { program = "/home/user/.config/alacritty/open-ghc-error.sh" }
  mouse.enabled = true
  regex = "GHC-\\d+"

The first hints.enabled is there to not break existing functionality. See the default section at Alacritty

run

chmod +x open-ghc-error.sh
13 Likes

TIL: ghc 9.10 links to ghc error index

1 Like