AutoYADM commit: 2025-03-13 16:00:06

This commit is contained in:
Daniel Fichtinger 2025-03-13 16:00:06 -04:00
parent ce3f0e9c5d
commit 436813ee12
3 changed files with 55 additions and 1 deletions

View file

@ -88,7 +88,6 @@ C-f = "jump_forward"
# a = "append_mode_same_line" # a = "append_mode_same_line"
tab = "trim_selections" tab = "trim_selections"
C-k = "signature_help" C-k = "signature_help"
C-g = [":new", ":insert-output lazygit", ":buffer-close!", ":redraw"]
"\\" = ":format" "\\" = ":format"
"+" = ":reflow" "+" = ":reflow"
ret = "goto_word" ret = "goto_word"
@ -132,6 +131,14 @@ A-l = "move_prev_sub_word_start"
C-d = ["page_cursor_half_down", "align_view_center"] C-d = ["page_cursor_half_down", "align_view_center"]
C-u = ["page_cursor_half_up", "align_view_center"] C-u = ["page_cursor_half_up", "align_view_center"]
# git stuff
[keys.normal.space.g]
# blame
b = ":sh git -C $(dirname $(realpath %{buffer_name})) blame -L %{cursor_line},%{cursor_line} $(realpath %{buffer_name})"
# lazygit
g = [":new", ":insert-output lazygit", ":buffer-close!", ":redraw"]
o = ":sh ~/.config/helix/scripts/get_git_provider_url.fish %{buffer_name} %{cursor_line} | wl-copy"
[keys.normal."["] [keys.normal."["]
x = "extend_line_above" x = "extend_line_above"
[keys.normal.space] [keys.normal.space]

View file

@ -0,0 +1,46 @@
#!/usr/bin/env fish
function get_git_provider_url --argument filename line_number
# Check if inside a git repository
if not git rev-parse --is-inside-work-tree >/dev/null 2>&1
echo "Error: Not inside a git repository."
return 1
end
# Get the remote URL
set remote_url (git config --get remote.origin.url)
if test -z "$remote_url"
echo "Error: No remote origin found."
return 1
end
# Determine the provider (GitHub, GitLab, etc.)
if string match -q '*github.com*' $remote_url
set provider github
else if string match -q '*gitlab.com*' $remote_url
set provider gitlab
else
echo "Error: Unsupported git provider."
return 1
end
# Extract the repo path and branch
set repo_path (echo $remote_url | perl -nE 'say $2 if /\.com(:|\/)(.*)\.git/')
set branch (git rev-parse --abbrev-ref HEAD)
# Generate the URL based on the provider
switch $provider
case github
echo "https://github.com/$repo_path/blob/$branch/$filename#L$line_number"
case gitlab
echo "https://gitlab.com/$repo_path/-/blob/$branch/$filename#L$line_number"
end
end
# Ensure correct number of arguments
if [ (count $argv) -ne 2 ]
echo "Usage: script.fish <filename> <line_number>"
return 1
end
get_git_provider_url $argv[1] $argv[2]

View file

@ -1 +1,2 @@
zsh -ic 'lg;exit' zsh -ic 'lg;exit'
zsh -ic 'chmod +x get_git_provider_url.fish;exit'