batpipe: Change the install commands to enable color automatically

This commit is contained in:
Ethan P 2021-04-04 14:22:39 -07:00
parent 672b4814ec
commit 6497bc04a0
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -81,11 +81,30 @@ if [[ "$#" -eq 0 ]]; then
printc '%{YELLOW}set -e %{CLEAR}LESSCLOSE;\n'
;;
*) # Bash-like
printc '%{MAGENTA}LESSOPEN%{YELLOW}=%{CYAN}"|%s %%s"%{CLEAR};\n' "$SELF"
printc '%{MAGENTA}LESSOPEN%{CLEAR}=%{CYAN}"|%s %%s"%{CLEAR};\n' "$SELF"
printc '%{YELLOW}export%{CLEAR} LESSOPEN;\n' "$SELF"
printc '%{YELLOW}unset%{CLEAR} LESSCLOSE;\n'
;;
esac
# Print the commands required to use color in `less` with `batpipe`.
if [[ -t 1 ]]; then
printc "\n%{DIM}# The following will enable colors when using batpipe with less:\n"
fi
# shellcheck disable=SC2016
case "$(basename -- "${detected_shell:bash}")" in
fish) # Fish
printc '%{YELLOW}set -x %{CLEAR}LESS %{CYAN}"%{MAGENTA}$LESS%{CYAN} -R"%{CLEAR};\n' "$SELF"
printc '%{YELLOW}set -x %{CLEAR}BATPIPE %{CYAN}"color"%{CLEAR};\n'
;;
*) # Bash-like
printc '%{MAGENTA}LESS%{CLEAR}=%{CYAN}"%{MAGENTA}$LESS%{CYAN} -R"%{CLEAR};\n' "$SELF"
printc '%{MAGENTA}BATPIPE%{CLEAR}=%{CYAN}"color"%{CLEAR};\n' "$SELF"
printc '%{YELLOW}export%{CLEAR} LESS;\n' "$SELF"
printc '%{YELLOW}export%{CLEAR} BATPIPE;\n' "$SELF"
;;
esac
exit 0
fi