-
Notifications
You must be signed in to change notification settings - Fork 1
/
rebuild_bat_config.sh
executable file
·52 lines (42 loc) · 1.07 KB
/
rebuild_bat_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
BAT_CONFIG_DIR="$(bat --config-dir)"
clone_or_update() {
local dir="${1}"
local repo_url="${2}"
if [ -d "${dir}" ]; then
echo "${dir} exists, updating…"
pushd "${dir}" > /dev/null || exit 8
git pull
popd > /dev/null || exit 9
else
echo "${dir} doesn't exist, cloning…"
git clone "${repo_url}" "${dir}"
fi
}
echo "Rebuilding bat config in ${BAT_CONFIG_DIR}…"
##
# Syntaxes
##
BAT_SYNTAXES="${BAT_CONFIG_DIR}/syntaxes"
mkdir -p "${BAT_SYNTAXES}"
cd "${BAT_SYNTAXES}" || (echo "Unable to cd to ${BAT_SYNTAXES}" && exit 2)
# List syntaxes here!
clone_or_update "Ledger" "https://github.com/vqv/Ledger3.git"
##
# Themes
##
BAT_THEMES="${BAT_CONFIG_DIR}/themes"
mkdir -p "${BAT_THEMES}"
cd "${BAT_THEMES}" || (echo "Unable to cd to ${BAT_THEMES}" && exit 2)
# List themes here!
# None right now…
echo "Rebuilding bat cache…"
bat cache --build
last="$?"
if [ "${last}" -eq 0 ]; then
echo "It probably worked!"
else
echo "It probably failed."
echo "Reset with [bat cache --clear] if things went real bad."
exit "${last}"
fi