2021-12-20 03:27:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# ---------- sys ---------
|
|
|
|
lowercase=false
|
|
|
|
file=""
|
2021-12-22 15:21:19 +00:00
|
|
|
prefix=""
|
2021-12-20 03:27:15 +00:00
|
|
|
|
|
|
|
this_script=$(basename "$0")
|
|
|
|
script_help=$( cat << EOF
|
2021-12-30 00:50:02 +00:00
|
|
|
This script updates colors from Catppuccin v0.1.1 to v0.1.2
|
|
|
|
You can find previous versions of this script in each release.
|
2021-12-20 03:27:15 +00:00
|
|
|
|
|
|
|
Usages:
|
|
|
|
#0: ${this_script} <flag> [arg]
|
|
|
|
|
|
|
|
Flags:
|
2021-12-22 15:21:19 +00:00
|
|
|
-f, --file specify file (mandatory)
|
|
|
|
-l, --lowercase replaces with lowercased hex codes
|
|
|
|
-p, --prefix specify which prefix to use for the hex codes. Surround it with double quotes if needed.
|
|
|
|
-h, --help see this message
|
2021-12-20 03:27:15 +00:00
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
|
|
|
declare -A colors=(
|
|
|
|
# <old> -> new
|
2022-01-07 00:56:16 +00:00
|
|
|
["C6AAE8"]='DDB6F2' # mauve
|
|
|
|
["E5B4E2"]='F5C2E7' # pink
|
|
|
|
["E49CB3"]='E8A2AF' # maroon
|
|
|
|
["E38C8F"]='F28FAD' # red
|
|
|
|
["F7BE95"]='F8BD96' # peach
|
|
|
|
["ECDDAA"]='FAE3B0' # yellow
|
|
|
|
["B1E1A6"]='ABE9B3' # green
|
|
|
|
["B7E5E6"]='B5E8E0' # teal
|
|
|
|
["A3B9EF"]='96CDFB' # blue
|
|
|
|
["92D2E8"]='89DCEB' # sky
|
|
|
|
["15121C"]='131020' # black0
|
|
|
|
["1B1923"]='1A1823' # black1
|
|
|
|
["1E1E28"]='1E1D2F' # black2
|
|
|
|
["332E41"]='302D41' # black3
|
|
|
|
["DFDEF1"]='D9E0EE' # white
|
2021-12-20 03:27:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
function update_colors() {
|
|
|
|
capitalization_char='\U' # uppercase
|
|
|
|
[[ $lowercase == true ]] && {
|
|
|
|
capitalization_char='\L' # lowercase
|
|
|
|
}
|
|
|
|
for clr in "${!colors[@]}"; do
|
|
|
|
echo -e " + ${clr} -> ${colors[$clr]}"
|
2021-12-22 15:21:19 +00:00
|
|
|
sed -i "s/${clr}/${prefix}${capitalization_char}${colors[$clr]}/gI" "$file"
|
2021-12-20 03:27:15 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
if [[ ! "$#" -gt 0 ]]; then
|
|
|
|
echo -e "INFO: Please provide the file you want to update to Catppuccin v0.1.1"
|
|
|
|
else
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
-f | --file)
|
|
|
|
file=$2
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-l | --lowercase)
|
|
|
|
lowercase=true
|
|
|
|
;;
|
2021-12-22 15:21:19 +00:00
|
|
|
-p | --prefix)
|
|
|
|
prefix=$2
|
|
|
|
shift
|
|
|
|
;;
|
2021-12-20 03:27:15 +00:00
|
|
|
-h | --help)
|
|
|
|
echo "$script_help"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: command ($1) not recognized"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
[[ -f $file ]] && {
|
|
|
|
echo -e "INFO: Updating colors..."
|
|
|
|
update_colors "${1}"
|
|
|
|
} || echo "ERROR: File ${1} does not exist"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|