-
Notifications
You must be signed in to change notification settings - Fork 3
/
profile_helper.sh
executable file
·34 lines (26 loc) · 859 Bytes
/
profile_helper.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
#!/usr/bin/env bash
_ALACRITTY_YML="${HOME}/.config/alacritty/alacritty.yml"
echo "export _ALACRITTY_YML=${_ALACRITTY_YML}"
cat << 'FUNC'
_add() {
local theme="$1"
yq -i eval-all '. as $item ireduce ({}; . * $item )' "${_ALACRITTY_YML}" "${_ALACRITTY_SHELL}/themes/${theme}.yml"
_alacritty "${theme}"
}
FUNC
cat << 'FUNC'
_alacritty() {
local theme="$1"
yq -i eval-all ".colors alias = \"${theme}\"" "${_ALACRITTY_YML}"
}
FUNC
themes=$(sed -n 's/^\(.*\): &.*/\1/p' "${_ALACRITTY_YML}" | sed -r 's/ //g')
for theme in $themes; do
alacritty_func_name="alacritty_${theme}"
echo "alias $alacritty_func_name=\"_alacritty $theme\""
done
for theme in "${_ALACRITTY_SHELL}"/themes/*.yml; do
filename=$(basename -s .yml "${theme}")
alacritty_func_name="add_alacritty_${filename}"
echo "alias $alacritty_func_name=\"_add ${filename}\""
done