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='
61 local cache_dir="$(bat --cache-dir)"
62 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
63 _print_command "$BAT" "--list-languages"
64 echo "Found custom syntax set."
67 if [[ -f "${cache_dir}/themes.bin" ]]; then
68 _print_command "$BAT" "--list-themes"
69 echo "Found custom theme set."
74 if [[ -f "$("$BAT" --config-file)" ]]; then
75 _out_fence cat "$("$BAT" --config-file)"
80 _bat_wrapper_:detect_wrapper() {
82 if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then
83 _out_fence cat "$(which "${bat}")"
87 printf "\nNo wrapper script for '%s'.\n" "${bat}"
90 _bat_wrapper_:detect_wrapper bat
91 if [[ "$BAT" != "bat" ]]; then
92 _bat_wrapper_:detect_wrapper "$BAT"
96_bat_wrapper_function_:run() {
97 _bat_wrapper_function_:detect_wrapper() {
99 case "$("$SHELL" --version | head -n 1)" in
101 if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &> /dev/null; then
102 _out_fence "$SHELL" --login -i -c "functions ${command}"
107 local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
108 if grep 'function' <<< "$type" &> /dev/null; then
109 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
111 elif grep 'alias' <<< "$type" &> /dev/null; then
112 _out_fence "$SHELL" --login -i -c "type ${command}"
117 echo "Unable to determine if a wrapper function for '${command}' is set."
120 printf "\nNo wrapper function for '%s'.\n" "${command}"
123 _bat_wrapper_function_:detect_wrapper bat
124 _bat_wrapper_function_:detect_wrapper cat
125 if [[ "$BAT" != "bat" ]]; then
126 _bat_wrapper_function_:detect_wrapper "$BAT"
133 if command -v "sw_vers" &> /dev/null; then _out sw_vers; fi
134 if command -v "lsb_release" &> /dev/null; then _out lsb_release -a; fi
138 _out less --version | head -n1
141# -----------------------------------------------------------------------------
143# -----------------------------------------------------------------------------
147 printf ' %s' "$@" 1>&2
153 "$@" 2>&1 | sed 's/$/ /'
164 tput "$@" 1>&2 2> /dev/null
168 printf " - %s\n" "$1" 1>&2
176--------------------------------------------------------------------------------
177This script runs some harmless commands to collect information about your
178system and bat configuration. It will give you a small preview of the commands
179that will be run, and ask consent before running them. Once completed, it will
180output a small report that you can review and copy into the issue description.
181--------------------------------------------------------------------------------
186 printf "The following data will be collected:\n" 1>&2
193 printf "\nThe following commands will be run:\n" 1>&2
195 declare -f "_$1_:run" \
196 | sed 's/^ *//; s/;$//' \
197 | grep '^_out[^ ]* ' \
198 | sed 's/^_out[^ ]* //' \
199 | sed "s/\"\$BAT\"/$BAT/" 1>&2
205 _tput cup "$(($( tput lines || echo 22) - 2))"
207 read -er -p "Collect $(sed 's/_/ /' <<< "$1") data? [Y/n] " response
209 Y | y | yes | '') return 0 ;;
210 N | n | no) return 1 ;;
218 printf "%s\n%s\n" "$module" "$(printf "%${#module}s" | tr ' ' '-')"
222# -----------------------------------------------------------------------------
224# -----------------------------------------------------------------------------
226# Tell the user if their executable isn't named "bat".
227if [[ "$BAT" != "bat" ]] && [[ "$1" != '-y' ]]; then
228 trap '_tput rmcup; exit 1' INT
233 printf "The %s executable on your system is named '%s'.\n%s\n" "bat" "$BAT" \
234 "If your issue is related to installation, please check that this isn't the issue."
236 printf "Press any key to continue...\n"
242if [[ "$1" == '-y' ]]; then
243 _modules_consented=("${_modules[@]}")
245 trap '_tput rmcup; exit 1' INT
247 for _module in "${_modules[@]}"; do
248 if _ask_module "$_module"; then
249 _modules_consented+=("$_module")
255# Collect information.
256for _module in "${_modules_consented[@]}"; do
257 _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