Skip to content

Commit 5ab7996

Browse files
committed
fix: Resolve 'bat' command for OS compatibility
1 parent f5e67cb commit 5ab7996

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

gh-notify

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ process_url() {
318318
local type="$1" url="$2"
319319
local number prerelease
320320
if command grep -q "Commit" <<<"$type"; then
321-
basename "$url" | command head -c 7
321+
command basename "$url" | command head -c 7
322322
elif command grep -q "Release" <<<"$type"; then
323323
if IFS=$'\t' read -r number prerelease < <(command gh api "$url" \
324324
--cache=100h \
@@ -360,15 +360,18 @@ process_discussion() {
360360
}
361361

362362
highlight_output() {
363+
local bat_cmd
363364
if command -v delta >/dev/null; then
364365
# https://dandavison.github.io/delta
365366
command delta --width "${FZF_PREVIEW_COLUMNS:-${COLUMNS:-100}}" --paging=never
366-
elif command -v bat >/dev/null; then
367-
# https://github.com/sharkdp/bat
368-
command bat --color=always --plain --language diff --no-pager \
369-
--terminal-width="${FZF_PREVIEW_COLUMNS:-${COLUMNS:-100}}"
370367
else
371-
command cat
368+
# Resolve 'bat' command (could be installed as 'bat' or 'batcat' depends on the OS)
369+
if bat_cmd=$(command -v bat || command -v batcat); then
370+
command $bat_cmd --color=always --plain --language diff --no-pager \
371+
--terminal-width="${FZF_PREVIEW_COLUMNS:-${COLUMNS:-100}}"
372+
else
373+
command cat
374+
fi
372375
fi
373376
}
374377

0 commit comments

Comments
 (0)