#!/usr/bin/env fish
{{- $batcmd := "cat" -}}
{{- if lookPath "bat" -}}
{{-   $batcmd = "bat" -}}
{{- else if lookPath "batcat" -}}
{{-   $batcmd = "batcat" -}}
{{- end }}

set -gx BATDIFF_USE_DELTA true

function cat --wraps bat
    {{ $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 --position anywhere -- --help "--help 2>&1 | {{ $batcmd }} --plain --language=help"
