helix: rewrite scrit to pull gh remote url from selection

karitham.dev 5ee376d8 418f47bc

verified
Changed files
+12 -1
modules
home
dev
+12 -1
modules/home/dev/helix.nix
··· 46 46 settings = { 47 47 keys = let 48 48 plusMenu = { 49 - g = ":sh gh browse -n %{buffer_name}:%{cursor_line} | ${pkgs.wl-clipboard}/bin/wl-copy"; 49 + g = '' 50 + :sh ${pkgs.nushell}/bin/nu -c ' 51 + let line = ("%{selection_line_start}" | default "%{cursor_line}") 52 + let line_end = (if ("%{selection_line_end}" | is-not-empty) {$"-L%{selection_line_end}"} else "") 53 + let root = (${pkgs.git}/bin/git rev-parse --show-toplevel | str trim) 54 + let rel_path = ("%{file_path_absolute}" | path relative-to $root) 55 + let ref = (${pkgs.jujutsu}/bin/jj log -r `heads(::@ & remote_bookmarks())` -T `remote_bookmarks` | parse -r `(?<branch>[\w\d\/\-,\.]+)@origin` | get branch.0) 56 + let remote_url = (${pkgs.git}/bin/git remote get-url origin | str trim | if ($in | str contains '://') {$in} else $"https://($in | str replace ':' '/')" | url parse) 57 + let url = $"https://($remote_url.host)($remote_url.path)/blob/($ref)/($rel_path)#L($line)($line_end)" 58 + $url | ${pkgs.wl-clipboard}/bin/wl-copy 59 + ' 60 + ''; 50 61 b = ":echo %sh{git blame -L %{cursor_line},+1 %{buffer_name}}"; 51 62 p = ":sh echo %{buffer_name} | ${pkgs.wl-clipboard}/bin/wl-copy"; 52 63 };