Description
kitty allows clicking regions that look like URLs by manually looking for the pattern: known-prefix://url-chars
within mouse.c
.
I would like to see this feature expanded to accept any regex based pattern.
I have a script that pipes git log
output to fzf
. Each line looks like:
2575f3d4 ch12345 Git comment starts here
I'd like to be able to click on ch12345
to open it within a URL like: https://app.clubhouse.io/story/12345
Describe the solution you'd like
Re implement the URL detection feature to accept one or more regex patterns.
Describe alternatives you've considered
Attempt 1
Make my script detect the [cC][hH]([0-9]+)
pattern and emit OSC 8 hyperlinks within each line.
Though this works just fine with kitty alone, when the script pipes git output to fzf --ansi
, the latter eats up all hyperlinks as the give option does not go beyond processing ansi escapes.
Someone opened a similar bug on
fzf
more than 6 months ago; however, this issue has not been resolved to date.
Attempt 2
My next attempt was to add the following line to kitty.conf
:
map kitty_mod+o pass_selection_to_program kitty-open-helper.sh
#!/bin/bash
if [[ "$1" =~ [cC][hH]([0-9]+) ]]; then
xdg-open https://app.clubhouse.io/story/${BASH_REMATCH[1]}
else
exec "$@"
fi
However, the UX is a bit awkward: rather than simply reaching for the text and clicking it, I have to first double-click to select it and then CTRL+SHIFT+O to open it. (One more keyboard shortcut to remember.)
It would be nice if I could simply reach out and click the ch12345
text without having to select it first.
Attempt 3
Implement the approach as described within the Hints section.
This would work, but is different than the mouse based solution I am trying to come up with.