mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-01-21 04:38:36 +01:00
batpipe: Fix opened-in-less detection
This commit is contained in:
parent
26111f9cee
commit
998e2ff1a9
@ -115,10 +115,27 @@ BATPIPE_INSIDE_LESS=false
|
||||
BATPIPE_INSIDE_BAT=false
|
||||
TERM_WIDTH="$(term_width)"
|
||||
|
||||
if [[ "$(basename -- "$(parent_executable | cut -f1 -d' ')")" == less ]]; then
|
||||
BATPIPE_PARENT_EXECUTABLE_PID="$PPID"
|
||||
for i in 1 2 3; do
|
||||
BATPIPE_PARENT_EXECUTABLE="$(parent_executable "$BATPIPE_PARENT_EXECUTABLE_PID")"
|
||||
BATPIPE_PARENT_EXECUTABLE_BASENAME="$(basename -- "${BATPIPE_PARENT_EXECUTABLE}" | cut -d' ' -f1)"
|
||||
BATPIPE_PARENT_EXECUTABLE_PID="$(parent_executable_pid "$BATPIPE_PARENT_EXECUTABLE_PID")"
|
||||
|
||||
if [[ "${BATPIPE_PARENT_EXECUTABLE_BASENAME}" = "less" ]]; then
|
||||
BATPIPE_INSIDE_LESS=true
|
||||
elif [[ "$(basename -- "$(parent_executable | cut -f1 -d' ')")" == "$(basename -- "$EXECUTABLE_BAT")" ]]; then
|
||||
break
|
||||
elif [[ "${BATPIPE_PARENT_EXECUTABLE_BASENAME}" == "$(basename -- "$EXECUTABLE_BAT")" ]]; then
|
||||
BATPIPE_INSIDE_BAT=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "${BATPIPE_DEBUG:-}" ]]; then
|
||||
printf "batpipe debug:\n"
|
||||
printf " %s: %s\n" \
|
||||
"BATPIPE_INSIDE_LESS" "${BATPIPE_INSIDE_LESS}" \
|
||||
"BATPIPE_INSIDE_BAT" "${BATPIPE_INSIDE_BAT}"
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user