From d2f4982e389431b74357bbc108567ae0e1d912a5 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 26 Jun 2026 13:50:48 +0530 Subject: Add open selection in git remote url --- autoload/git.kak | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'autoload') diff --git a/autoload/git.kak b/autoload/git.kak index 59ac173..775cf0d 100644 --- a/autoload/git.kak +++ b/autoload/git.kak @@ -6,8 +6,6 @@ define-command gitui -params .. %{ gitu %arg{@} } -# TODO: Script to open git remote url (github/srht/gitlab/etc) - declare-user-mode git declare-user-mode git-r declare-user-mode git-d @@ -16,6 +14,7 @@ map global git s ': gitui' -docstring 'Git tui' map global git A ': git add %val{buffile}' -docstring 'Add file' map global git m ': git-line-blame' -docstring 'Blame selection lines' map global git M ': git-file-blame' -docstring 'Blame buffer file' +map global git l ': git-link' -docstring 'Open remote link to selection in file' map global git d ': enter-user-mode git-d' -docstring 'Diff mode' map global git-d d ': git-open-diff' -docstring 'Open staged files' @@ -53,3 +52,15 @@ define-command git-open-diff -params 0..1 %{ define-command git-open-commit -params 0..1 %{ eval %sh{ git show --name-only --pretty="" "$@" | sed 's/^/edit /' } } + +define-command git-link %{ + eval %sh{ + line_start=${kak_selection_desc%%.*} + tmp=${kak_selection_desc#*,} + line_end=${tmp%%.*} + link=$("$kak_config/scripts/git.clj" link "$kak_buffile" "$line_start" "$line_end") + xdg-open "$link" || true >/dev/null + echo "info '$link'" + } +} + -- cgit v1.3.1