Skip to content

Commit

Permalink
feat(helix): add tmux git-blame workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehsiao committed Aug 28, 2023
1 parent e19c4d2 commit 5096925
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dot_local/bin/executable_helix-git-blame
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Select Original pane
ORIGINAL_PANE=$(tmux select-pane -U)

# Capture the output of the original pane
PANE_OUTPUT=$(tmux capture-pane -p -t $ORIGINAL_PANE)

# Back to the bottom pane
tmux select-pane -D

# Extract file and line information
RES=$(echo "$PANE_OUTPUT" | rg -e "(?:NOR|INS|SEL)\s+(\S*)\s[^│]* (\d+):*.*" -o --replace '$1 $2')
FILE=$(echo $RES | choose 0)
LINE=$(echo $RES | choose 1)

# Run git blame and fzf commands
git blame -L $LINE,+100 $FILE --color-by-age --color-lines |
fzf --ansi \
--border \
--delimiter ':' \
--height '100%' \
--multi \
--print-query --exit-0 \
--scrollbar ''
1 change: 1 addition & 0 deletions private_dot_config/helix/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ hidden = false

[keys.normal.g]
q = ":reflow"
B = ":pipe-to tmux split-window -v helix-git-blame"

0 comments on commit 5096925

Please sign in to comment.