@@ -7,6 +7,12 @@ set -o pipefail
7export LC_ALL=C
7export LC_ALL=C
8export LANG=C
8export LANG=C
10+if command -v batcat &> /dev/null; then
10# -----------------------------------------------------------------------------
16# -----------------------------------------------------------------------------
12# -----------------------------------------------------------------------------
18# -----------------------------------------------------------------------------
@@ -41,33 +47,42 @@ _tool_:description() {
41# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
47# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43_bat_:run() {
49_bat_:run() {
44− _out bat --version
50+ _out "$BAT" --version
45 _out env | grep '^BAT_\|^PAGER='
51 _out env | grep '^BAT_\|^PAGER='
47 local cache_dir="$(bat --cache-dir)"
53 local cache_dir="$(bat --cache-dir)"
48 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
54 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
49− _print_command "bat" "--list-languages"
55+ _print_command "$BAT" "--list-languages"
50 echo "Found custom syntax set."
56 echo "Found custom syntax set."
53 if [[ -f "${cache_dir}/themes.bin" ]]; then
59 if [[ -f "${cache_dir}/themes.bin" ]]; then
54− _print_command "bat" "--list-themes"
60+ _print_command "$BAT" "--list-themes"
55 echo "Found custom theme set."
61 echo "Found custom theme set."
59_bat_config_:run() {
65_bat_config_:run() {
60− if [[ -f "$(bat --config-file)" ]]; then
66+ if [[ -f "$("$BAT" --config-file)" ]]; then
61− _out_fence cat "$(bat --config-file)"
67+ _out_fence cat "$("$BAT" --config-file)"
65_bat_wrapper_:run() {
71_bat_wrapper_:run() {
72+ _bat_wrapper_:detect_wrapper() {
66− if file "$(which bat)" | grep "text executable" &> /dev/null; then
74+ if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then
67− _out_fence cat "$(which bat)"
75+ _out_fence cat "$(which "${bat}")"
79+ printf "\nNo wrapper script for '%s'.\n" "${bat}"
82+ _bat_wrapper_:detect_wrapper bat
83+ if [[ "$BAT" != "bat" ]]; then
84+ _bat_wrapper_:detect_wrapper "$BAT"
70− printf "\nNo wrapper script.\n"
73_bat_wrapper_function_:run() {
88_bat_wrapper_function_:run() {
@@ -75,17 +90,17 @@ _bat_wrapper_function_:run() {
75 local command="$1"
90 local command="$1"
76 case "$("$SHELL" --version | head -n 1)" in
91 case "$("$SHELL" --version | head -n 1)" in
78− if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &>/dev/null; then
93+ if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &> /dev/null; then
79 _out_fence "$SHELL" --login -i -c "functions ${command}"
94 _out_fence "$SHELL" --login -i -c "functions ${command}"
83− *bash*|*zsh*)
98+ *bash* | *zsh*)
84 local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
99 local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
85− if grep 'function' <<< "$type" &>/dev/null; then
100+ if grep 'function' <<< "$type" &> /dev/null; then
86 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
101 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
88− elif grep 'alias' <<< "$type" &>/dev/null; then
103+ elif grep 'alias' <<< "$type" &> /dev/null; then
89 _out_fence "$SHELL" --login -i -c "type ${command}"
104 _out_fence "$SHELL" --login -i -c "type ${command}"
@@ -99,6 +114,9 @@ _bat_wrapper_function_:run() {
100 _bat_wrapper_function_:detect_wrapper bat
115 _bat_wrapper_function_:detect_wrapper bat
101 _bat_wrapper_function_:detect_wrapper cat
116 _bat_wrapper_function_:detect_wrapper cat
117+ if [[ "$BAT" != "bat" ]]; then
118+ _bat_wrapper_function_:detect_wrapper "$BAT"
104_system_:run() {
122_system_:run() {
@@ -169,7 +187,8 @@ EOF
169 declare -f "_$1_:run" \
187 declare -f "_$1_:run" \
170 | sed 's/^ *//; s/;$//' \
188 | sed 's/^ *//; s/;$//' \
171 | grep '^_out[^ ]* ' \
189 | grep '^_out[^ ]* ' \
172− | sed 's/^_out[^ ]* //' 1>&2
190+ | sed 's/^_out[^ ]* //' \
191+ | sed "s/\"\$BAT\"/$BAT/" 1>&2
175 printf "\n" 1>&2
194 printf "\n" 1>&2
@@ -196,6 +215,16 @@ _run_module() {
196# Functions:
215# Functions:
197# -----------------------------------------------------------------------------
216# -----------------------------------------------------------------------------
218+# Tell the user if their executable isn't named "bat".
219+if [[ "$BAT" != "bat" ]] && [[ "$1" != '-y' ]]; then
221+ printf "The %s executable on your system is named '%s'.\n%s\n" "bat" "$BAT" \
222+ "If your issue is related to installation, please check that this isn't the issue."
224+ printf "Press any key to continue...\n"
199# Ask for consent.
228# Ask for consent.
200if [[ "$1" == '-y' ]]; then
229if [[ "$1" == '-y' ]]; then
201 _modules_consented=("${_modules[@]}")
230 _modules_consented=("${_modules[@]}")