21 lines
757 B
Text
21 lines
757 B
Text
provide-module url-open %∴
|
|
declare-option -docstring %{
|
|
Command for opening URLs.
|
|
} str url_open_cmd 'xdg-open %s'
|
|
define-command -docstring %{
|
|
Open the URL the cursor is on with url_open_cmd.
|
|
} url-open %{
|
|
evaluate-commands -save-regs 'ab' %{
|
|
set-register b 'https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)'
|
|
try %{
|
|
execute-keys -draft '<a-a><a-w>s<c-r>b<ret>"ay'
|
|
nop %sh{
|
|
eval "$(printf "$kak_opt_url_open_cmd" "$kak_reg_a")"
|
|
}
|
|
echo "Opened %reg{a}"
|
|
} catch %{
|
|
fail 'Cursor is not on a URL!'
|
|
}
|
|
}
|
|
}
|
|
∴
|