Skip to content

Commit

Permalink
forgit show: add key binding to display the commit message
Browse files Browse the repository at this point in the history
Ctrl-T can now be used to toggle between showing the diff and the commit
message in the fzf preview window.

Also add a border label to indicate which preview is currently shown, as
well as a border showing the key bindings.

This requires fzf >= 0.49.0.
  • Loading branch information
carlfriedrich committed Jan 6, 2025
1 parent 580c5cb commit 82261b7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ _forgit_show_view() {
repo=$(git rev-parse --show-toplevel)
cd "$repo" || return 1
echo "$input_line" | _forgit_get_files_from_diff_line | xargs -0 \
"$FORGIT" exec_show "${commit}" -U"$diff_context" -- | _forgit_pager diff
"$FORGIT" exec_show "${commit}^{commit}" -U"$diff_context" -- | _forgit_pager diff
}

_forgit_show_enter() {
Expand Down Expand Up @@ -383,6 +383,15 @@ _forgit_show() {
+m -0 --bind=\"enter:execute($FORGIT show_enter {} $escaped_commit | $FORGIT pager enter)\"
--preview=\"$FORGIT show_view {} '$_forgit_preview_context' $escaped_commit\"
--bind=\"alt-e:execute($FORGIT edit_diffed_file {})+refresh-preview\"
--bind 'ctrl-t:transform:[[ ! \$FZF_PREVIEW_LABEL =~ Diff ]] &&
echo \"change-preview-label( Diff )+refresh-preview\" ||
echo \"change-preview-label( Commit Message )+refresh-preview\"'
--preview '[[ \$FZF_PREVIEW_LABEL =~ Diff ]] &&
$FORGIT show_view {} '$_forgit_preview_context' $escaped_commit ||
git show --quiet --color=always \${FZF_PROMPT%% *}'
--border=bottom
--border-label=' [CTRL+T] toggle preview - [ALT+E] edit file '
--preview-label=' Diff '
$FORGIT_DIFF_FZF_OPTS
--prompt=\"${commit} > \"
"
Expand Down

0 comments on commit 82261b7

Please sign in to comment.