From e9f020b0e3284ffa56430c796ed325adc7871698 Mon Sep 17 00:00:00 2001 From: punkfairie <23287005+punkfairie@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:36:59 -0700 Subject: [PATCH] Update .config/fish/conf.d/30-bat.fish --- dot_config/fish/conf.d/30-bat.fish.tmpl | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/dot_config/fish/conf.d/30-bat.fish.tmpl b/dot_config/fish/conf.d/30-bat.fish.tmpl index f466f75..2361d30 100644 --- a/dot_config/fish/conf.d/30-bat.fish.tmpl +++ b/dot_config/fish/conf.d/30-bat.fish.tmpl @@ -1,22 +1,16 @@ #!/usr/bin/env fish +{{- $batcmd := "cat" -}} +{{- if lookPath "bat" -}} +{{- $batcmd = "bat" -}} +{{- else if lookPath "batcat" -}} +{{- $batcmd = "batcat" -}} +{{- end }} set -gx BATDIFF_USE_DELTA true -set -g batcmd - -if command -v bat &>/dev/null - set batcmd bat -else if command -v batcat &>/dev/null - set batcmd batcat -end - function cat --wraps bat - if command -v bat &>/dev/null - bat $argv - else if command -v batcat &>/dev/null - batcat $argv - end + {{ $batcmd }} $argv end -abbr -a B --position anywhere --set-cursor "% | $batcmd" -abbr -a --position anywhere -- -h "-h 2>&1 | $batcmd --plain --language=help" +abbr -a B --position anywhere --set-cursor "% | {{ $batcmd }}" +abbr -a --position anywhere -- -h "-h 2>&1 | {{ $batcmd }} --plain --language=help"