mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 19:57:46 +02:00
batpipe: Highlight unsupported files using bat
This commit is contained in:
parent
af9709452f
commit
5f5a5e87a9
@ -97,12 +97,12 @@ BATPIPE_INSIDE_LESS=false
|
|||||||
BATPIPE_INSIDE_BAT=false
|
BATPIPE_INSIDE_BAT=false
|
||||||
TERM_WIDTH="$(term_width)"
|
TERM_WIDTH="$(term_width)"
|
||||||
|
|
||||||
bat_if_not_bat() { cat; }
|
bat_if_not_bat() { bat "$@"; return $?; }
|
||||||
if [[ "$(basename -- "$(parent_executable "$(parent_executable_pid)"|cut -f1 -d' ')")" == less ]]; then
|
if [[ "$(basename -- "$(parent_executable "$(parent_executable_pid)"|cut -f1 -d' ')")" == less ]]; then
|
||||||
BATPIPE_INSIDE_LESS=true
|
BATPIPE_INSIDE_LESS=true
|
||||||
bat_if_not_bat() { bat "$@"; return $?; }
|
|
||||||
elif [[ "$(basename -- "$(parent_executable|cut -f1 -d' ')")" == "$(basename -- "$EXECUTABLE_BAT")" ]]; then
|
elif [[ "$(basename -- "$(parent_executable|cut -f1 -d' ')")" == "$(basename -- "$EXECUTABLE_BAT")" ]]; then
|
||||||
BATPIPE_INSIDE_BAT=true
|
BATPIPE_INSIDE_BAT=true
|
||||||
|
bat_if_not_bat() { cat "$@"; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -385,5 +385,12 @@ for viewer in "${BATPIPE_VIEWERS[@]}"; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# No supported viewer. Just pass it through.
|
# No supported viewer. Just pass it through (if using bat).
|
||||||
|
if [[ "$BATPIPE_INSIDE_BAT" = true ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# No supported viewer... highlight it using bat.
|
||||||
|
if [[ -f "$1" ]]; then
|
||||||
|
bat_if_not_bat "$1"
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user