2_modules=('system' 'bat' 'bat_config' 'bat_wrapper' 'bat_wrapper_function' 'tool')
11if ! command -v bat &>/dev/null; then
12 if command -v batcat &> /dev/null; then
17 "Unable to find a bat executable on your PATH." \
18 "Please ensure that 'bat' exists and is not named something else."
24# -----------------------------------------------------------------------------
26# -----------------------------------------------------------------------------
29 _collects "Version information for 'bat'."
30 _collects "Custom syntaxes and themes for 'bat'."
33_bat_config_:description() {
34 _collects "The environment variables used by 'bat'."
35 _collects "The 'bat' configuration file."
38_bat_wrapper_:description() {
39 _collects "Any wrapper script used by 'bat'."
42_bat_wrapper_function_:description() {
43 _collects "The wrapper function surrounding 'bat' (if applicable)."
46_system_:description() {
47 _collects "Operating system name."
48 _collects "Operating system version."
52 _collects "Version information for 'less'."
55# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 _out env | grep '^BAT_\|^PAGER='
62 cache_dir="$($BAT --cache-dir)"
63 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
64 _print_command "$BAT" "--list-languages"
65 echo "Found custom syntax set."
68 if [[ -f "${cache_dir}/themes.bin" ]]; then
69 _print_command "$BAT" "--list-themes"
70 echo "Found custom theme set."
75 if [[ -f "$("$BAT" --config-file)" ]]; then
76 _out_fence cat "$("$BAT" --config-file)"
81 _bat_wrapper_:detect_wrapper() {
83 if file "$(command -v "${bat}")" | grep "text executable" &> /dev/null; then
84 _out_fence cat "$(command -v "${bat}")"
88 printf "\nNo wrapper script for '%s'.\n" "${bat}"
91 _bat_wrapper_:detect_wrapper bat
92 if [[ "$BAT" != "bat" ]]; then
93 _bat_wrapper_:detect_wrapper "$BAT"
97_bat_wrapper_function_:run() {
98 _bat_wrapper_function_:detect_wrapper() {
100 case "$("$SHELL" --version | head -n 1)" in
102 if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &> /dev/null; then
103 _out_fence "$SHELL" --login -i -c "functions ${command}"
109 type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
110 if grep 'function' <<< "$type" &> /dev/null; then
111 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
113 elif grep 'alias' <<< "$type" &> /dev/null; then
114 _out_fence "$SHELL" --login -i -c "type ${command}"
119 echo "Unable to determine if a wrapper function for '${command}' is set."
122 printf "\nNo wrapper function for '%s'.\n" "${command}"
125 _bat_wrapper_function_:detect_wrapper bat
126 _bat_wrapper_function_:detect_wrapper cat
127 if [[ "$BAT" != "bat" ]]; then
128 _bat_wrapper_function_:detect_wrapper "$BAT"
135 if command -v "sw_vers" &> /dev/null; then _out sw_vers; fi
136 if command -v "lsb_release" &> /dev/null; then _out lsb_release -a; fi
140 _out less --version | head -n1
143# -----------------------------------------------------------------------------
145# -----------------------------------------------------------------------------
149 printf ' %s' "$@" 1>&2
155 "$@" 2>&1 | sed 's/$/ /'
166 tput "$@" 1>&2 2> /dev/null
170 printf " - %s\n" "$1" 1>&2
178--------------------------------------------------------------------------------
179This script runs some harmless commands to collect information about your
180system and bat configuration. It will give you a small preview of the commands
181that will be run, and ask consent before running them. Once completed, it will
182output a small report that you can review and copy into the issue description.
183--------------------------------------------------------------------------------
188 printf "The following data will be collected:\n" 1>&2
195 printf "\nThe following commands will be run:\n" 1>&2
197 declare -f "_$1_:run" \
198 | sed 's/^ *//; s/;$//' \
199 | grep '^_out[^ ]* ' \
200 | sed 's/^_out[^ ]* //' \
201 | sed "s/\"\$BAT\"/$BAT/" 1>&2
207 _tput cup "$(($( tput lines || echo 22) - 2))"
209 read -er -p "Collect $(sed 's/_/ /' <<< "$1") data? [Y/n] " response
211 Y | y | yes | '') return 0 ;;
212 N | n | no) return 1 ;;
220 printf "%s\n%s\n" "$module" "$(printf "%${#module}s" | tr ' ' '-')"
224# -----------------------------------------------------------------------------
226# -----------------------------------------------------------------------------
228# Tell the user if their executable isn't named "bat".
229if [[ "$BAT" != "bat" ]] && [[ "$1" != '-y' ]]; then
230 trap '_tput rmcup; exit 1' INT
235 printf "The %s executable on your system is named '%s'.\n%s\n" "bat" "$BAT" \
236 "If your issue is related to installation, please check that this isn't the issue."
238 printf "Press any key to continue...\n"
244if [[ "$1" == '-y' ]]; then
245 _modules_consented=("${_modules[@]}")
247 trap '_tput rmcup; exit 1' INT
249 for _module in "${_modules[@]}"; do
250 if _ask_module "$_module"; then
251 _modules_consented+=("$_module")
257# Collect information.
258for _module in "${_modules_consented[@]}"; do
259 _run_module "$_module" 2>&1
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list