From 8be1c63c18b4d1a9c75308bd50f9113b67d21798 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 1 Nov 2024 01:55:03 +0100 Subject: [PATCH] glog: Fix coloring when scrolling Due to the formatting placeholders sitting on the previous line, the coloring of the topmost line disappeared when scrolling (as the escape sequence scrolled away). This had the background that I wanted the code that sets up the format string to be very readable and if possible very close to the actual output. And since the colors have all different lengths I decided to place them on the previous line to have them out of the way. Fix this by placing the placeholders on the same output line while still maintaining a readable format string (code). This is done by joining the array without placing newlines so that it can now have multiple elements for one output line and formatting those as wished. --- .config/zsh/autoload/git/glog | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.config/zsh/autoload/git/glog b/.config/zsh/autoload/git/glog index f56c781..6f486be 100755 --- a/.config/zsh/autoload/git/glog +++ b/.config/zsh/autoload/git/glog @@ -24,23 +24,23 @@ git rev-parse || return # abbreviated commit hash (yellow), title and ref names local formatshort='--pretty=format:%C(yellow)%h %Creset%s%C(auto)%d' # Verbose format for the preview window on the right -# This array is stitched together with newlines later local -a format=( - '--pretty=format:%C(yellow)' # newline created by this eaten by %- - '%-Commit: %H%C(auto)' # yellow commit hash - ' %D%Cblue' # auto colored ref names (if any) - 'Author: %aN <%aE>%Cred' # blue author mail - 'AuthorDate: %ad%Cblue' # red author date - 'Commit: %cN <%cE>%Cred' # blue commiter mail - 'CommitDate: %cd%Cblue' # red commit date - 'Signer: %GS%Cgreen' # signer name - 'Key (%G?): %GK' # pgp key used to sign - '%Creset%C(bold)' # empty line - ' %s%Creset' # bold white subject - '' # newline - '%-b' # body - '' # newline + '--pretty=format:' + '%C(yellow)' 'Commit: ' '%H' '%n' # commit hash + '%C(auto)' ' ' '%D' '%n' # ref names (if any) + '%C(blue)' 'Author: ' '%aN <%aE>' '%n' # author mail + '%C(red)' 'AuthorDate: ' '%ad' '%n' # author date + '%C(blue)' 'Commit: ' '%cN <%cE>' '%n' # commiter mail + '%C(red)' 'CommitDate: ' '%cd' '%n' # commit date + '%C(blue)' 'Signer: ' '%GS' '%n' # signer name + '%C(green)' 'Key (%G?): ' '%GK' '%n' # pgp key used to sign + '%n' + '%C(reset)%C(bold)' ' %s%C(reset)' '%n' # subject + '%n' + '%-b' # body + '%n' ) +format="${(j::)format}" # Ignore the graph part at the beginning, then capture the commit hash and throw # away the rest of the line. @@ -56,7 +56,7 @@ EOT fzf_preview[construct]="$REPLY" read -r -d '' <