2_modules=('system' 'bat' 'bat_config' 'bat_wrapper' 'bat_wrapper_function' 'tool')
10# -----------------------------------------------------------------------------
12# -----------------------------------------------------------------------------
15 _collects "Version information for 'bat'."
16 _collects "Custom syntaxes and themes for 'bat'."
19_bat_config_:description() {
20 _collects "The environment variables used by 'bat'."
21 _collects "The 'bat' configuration file."
24_bat_wrapper_:description() {
25 _collects "Any wrapper script used by 'bat'."
28_bat_wrapper_function_:description() {
29 _collects "The wrapper function surrounding 'bat' (if applicable)."
32_system_:description() {
33 _collects "Operating system name."
34 _collects "Operating system version."
38 _collects "Version information for 'less'."
41# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45 _out env | grep '^BAT_\|^PAGER='
47 local cache_dir="$(bat --cache-dir)"
48 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
49 _print_command "bat" "--list-languages"
50 echo "Found custom syntax set."
53 if [[ -f "${cache_dir}/themes.bin" ]]; then
54 _print_command "bat" "--list-themes"
55 echo "Found custom theme set."
60 if [[ -f "$(bat --config-file)" ]]; then
61 _out_fence cat "$(bat --config-file)"
66 if file "$(which bat)" | grep "text executable" &> /dev/null; then
67 _out_fence cat "$(which bat)"
70 printf "\nNo wrapper script.\n"
73_bat_wrapper_function_:run() {
74 _bat_wrapper_function_:detect_wrapper() {
76 case "$("$SHELL" --version | head -n 1)" in
78 if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &>/dev/null; then
79 _out_fence "$SHELL" --login -i -c "functions ${command}"
84 local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
85 if grep 'function' <<< "$type" &>/dev/null; then
86 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
88 elif grep 'alias' <<< "$type" &>/dev/null; then
89 _out_fence "$SHELL" --login -i -c "type ${command}"
94 echo "Unable to determine if a wrapper function for '${command}' is set."
97 printf "\nNo wrapper function for '%s'.\n" "${command}"
100 _bat_wrapper_function_:detect_wrapper bat
101 _bat_wrapper_function_:detect_wrapper cat
107 if command -v "sw_vers" &> /dev/null; then _out sw_vers; fi
108 if command -v "lsb_release" &> /dev/null; then _out lsb_release -a; fi
112 _out less --version | head -n1
115# -----------------------------------------------------------------------------
117# -----------------------------------------------------------------------------
121 printf ' %s' "$@" 1>&2
127 "$@" 2>&1 | sed 's/$/ /'
138 tput "$@" 1>&2 2> /dev/null
142 printf " - %s\n" "$1" 1>&2
150--------------------------------------------------------------------------------
151This script runs some harmless commands to collect information about your
152system and bat configuration. It will give you a small preview of the commands
153that will be run, and ask consent before running them. Once completed, it will
154output a small report that you can review and copy into the issue description.
155--------------------------------------------------------------------------------
160 printf "The following data will be collected:\n" 1>&2
167 printf "\nThe following commands will be run:\n" 1>&2
169 declare -f "_$1_:run" \
170 | sed 's/^ *//; s/;$//' \
171 | grep '^_out[^ ]* ' \
172 | sed 's/^_out[^ ]* //' 1>&2
178 _tput cup "$(($( tput lines || echo 22) - 2))"
180 read -er -p "Collect $(sed 's/_/ /' <<< "$1") data? [Y/n] " response
182 Y | y | yes | '') return 0 ;;
183 N | n | no) return 1 ;;
191 printf "%s\n%s\n" "$module" "$(printf "%${#module}s" | tr ' ' '-')"
195# -----------------------------------------------------------------------------
197# -----------------------------------------------------------------------------
200if [[ "$1" == '-y' ]]; then
201 _modules_consented=("${_modules[@]}")
203 trap '_tput rmcup; exit 1' INT
205 for _module in "${_modules[@]}"; do
206 if _ask_module "$_module"; then
207 _modules_consented+=("$_module")
213# Collect information.
214for _module in "${_modules_consented[@]}"; do
215 _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