@@ -227,13 +227,14 @@ print_notifs() {
227
227
fi
228
228
}
229
229
230
- diff_pager () {
230
+ highlight_output () {
231
231
if type -p delta > /dev/null; then
232
232
# https://dandavison.github.io/delta
233
- delta --width " ${FZF_PREVIEW_COLUMNS:- $COLUMNS } "
233
+ delta --width " ${FZF_PREVIEW_COLUMNS:- ${ COLUMNS:- 100} } " --paging=never
234
234
elif type -p bat > /dev/null; then
235
235
# https://github.com/sharkdp/bat
236
- bat --plain --language diff
236
+ bat --color=always --plain --language diff --no-pager \
237
+ --terminal-width=" ${FZF_PREVIEW_COLUMNS:- ${COLUMNS:- 100} } "
237
238
else
238
239
cat
239
240
fi
@@ -278,6 +279,10 @@ view_notification() {
278
279
IFS=' ' read -r _ _ _ _ date time repo type number _ <<< " $1"
279
280
printf " [%s %s - %s]\n" " $date " " $time " " $type "
280
281
case " $type " in
282
+ Commit)
283
+ gh api --header " $GH_REST_API_VERSION " --cache=24h \
284
+ --method GET " repos/$repo /commits/$number " --jq ' .files[].patch' | highlight_output
285
+ ;;
281
286
Issue)
282
287
# use the '--comments' flag only if 'all_comments' exists and is not null
283
288
gh issue view " $number " --repo " $repo " ${all_comments: +" --comments" }
@@ -326,7 +331,7 @@ select_notif() {
326
331
# 'SHELL="$(which bash)"' is needed to use exported functions when the default shell
327
332
# is not bash
328
333
export -f print_help_text print_notifs get_notifs
329
- export -f diff_pager open_in_browser view_notification
334
+ export -f highlight_output open_in_browser view_notification
330
335
export -f mark_all_read mark_individual_read
331
336
# The 'die' function is not exported because 'fzf' warns you about the error in
332
337
# a failed 'print_notifs' call, but does not display the message.
@@ -342,8 +347,8 @@ select_notif() {
342
347
--bind " change:first" \
343
348
--bind " ctrl-a:execute-silent(mark_all_read {})+reload:print_notifs || true" \
344
349
--bind " ctrl-b:execute-silent:open_in_browser {}" \
345
- --bind " ctrl-d:toggle-preview+change-preview:if grep -q PullRequest <<<{8}; then gh pr diff {9} --repo {7} | diff_pager ; else view_notification {}; fi" \
346
- --bind " ctrl-p:toggle-preview+change-preview:if grep -q PullRequest <<<{8}; then gh pr diff {9} --patch --repo {7} | diff_pager ; else view_notification {}; fi" \
350
+ --bind " ctrl-d:toggle-preview+change-preview:if grep -q PullRequest <<<{8}; then gh pr diff {9} --repo {7} | highlight_output ; else view_notification {}; fi" \
351
+ --bind " ctrl-p:toggle-preview+change-preview:if grep -q PullRequest <<<{8}; then gh pr diff {9} --patch --repo {7} | highlight_output ; else view_notification {}; fi" \
347
352
--bind " ctrl-r:reload:print_notifs || true" \
348
353
--bind " ctrl-t:execute-silent(mark_individual_read {})+reload:print_notifs || true" \
349
354
--bind " enter:execute:view_notification --all_comments {} | less ${less_args[*]} >/dev/tty" \
0 commit comments