on master help sign in
Add custom theme/syntax detection to info.sh
e037afeEthan P
diagnostics/info.sh+18−5
@@ -2,6 +2,7 @@
2_modules=('system' 'bat' 'bat_config' 'bat_wrapper' 'bat_wrapper_function' 'tool')
2_modules=('system' 'bat' 'bat_config' 'bat_wrapper' 'bat_wrapper_function' 'tool')
3_modules_consented=()
3_modules_consented=()
4
4
5+set -o pipefail
5
6
6# -----------------------------------------------------------------------------
7# -----------------------------------------------------------------------------
7# Modules:
8# Modules:
@@ -9,6 +10,7 @@ _modules_consented=()
9
10
10_bat_:description() {
11_bat_:description() {
11 _collects "Version information for 'bat'."
12 _collects "Version information for 'bat'."
13+ _collects "Custom syntaxes and themes for 'bat'."
12}
14}
13
15
14_bat_config_:description() {
16_bat_config_:description() {
@@ -39,11 +41,22 @@ _tool_:description() {
39_bat_:run() {
41_bat_:run() {
40 _out bat --version
42 _out bat --version
41 _out env | grep '^BAT_\|^PAGER='
43 _out env | grep '^BAT_\|^PAGER='
44+
45+ local cache_dir="$(bat --cache-dir)"
46+ if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
47+ _print_command "bat" "--list-languages"
48+ echo "Found custom syntax set."
49+ fi
50+
51+ if [[ -f "${cache_dir}/themes.bin" ]]; then
52+ _print_command "bat" "--list-themes"
53+ echo "Found custom theme set."
54+ fi
42}
55}
43
56
44_bat_config_:run() {
57_bat_config_:run() {
45− if [[ -f "$(bat --config-file)" ]]; then
58+ if [[ -f "$(bat --config-file)" ]]; then
46− _out_fence cat "$(bat --config-file)";
59+ _out_fence cat "$(bat --config-file)";
47 fi
60 fi
48}
61}
49
62
@@ -57,7 +70,7 @@ _bat_wrapper_:run() {
57
70
58_bat_wrapper_function_:run() {
71_bat_wrapper_function_:run() {
59 case "$("$SHELL" --version | head -n 1)" in
72 case "$("$SHELL" --version | head -n 1)" in
60− *fish*)
73+ *fish*)
61 if "$SHELL" --login -c 'type bat' 2>&1 | grep 'function' &>/dev/null; then
74 if "$SHELL" --login -c 'type bat' 2>&1 | grep 'function' &>/dev/null; then
62 _out_fence "$SHELL" --login -c 'functions bat'
75 _out_fence "$SHELL" --login -c 'functions bat'
63 fi ;;
76 fi ;;
@@ -67,7 +80,7 @@ _bat_wrapper_function_:run() {
67 _out_fence "$SHELL" --login -c 'declare -f bat'
80 _out_fence "$SHELL" --login -c 'declare -f bat'
68 fi ;;
81 fi ;;
69
82
70− *)
83+ *)
71 echo "Unable to determine if a wrapper function is set."
84 echo "Unable to determine if a wrapper function is set."
72 return ;;
85 return ;;
73 esac
86 esac
@@ -135,7 +148,7 @@ EOF
135 _tput sgr0
148 _tput sgr0
136 "_$1_:description"
149 "_$1_:description"
137 _tput sgr0
150 _tput sgr0
138−
151+
139 # Print preview.
152 # Print preview.
140 _tput setaf 3
153 _tput setaf 3
141 printf "\nThe following commands will be run:\n" 1>&2
154 printf "\nThe following commands will be run:\n" 1>&2