1
0
mirror of https://github.com/Mayccoll/Gogh.git synced 2023-08-10 21:12:46 +03:00

Merge pull request #279 from ivanmilov/master

Add support for alacritty
This commit is contained in:
Mayccoll 2021-02-22 10:34:51 -05:00 committed by GitHub
commit c4882c5ac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 0 deletions

23
apply-alacritty.py Executable file
View File

@ -0,0 +1,23 @@
import io
import json
import sys
from appdirs import user_config_dir
from ruamel.yaml import YAML # use ruamel.yaml to preserve comments in config
yaml = YAML()
conf = user_config_dir('alacritty') + "/alacritty.yml"
# Read alacritty config
with open(conf, 'r') as stream:
data_loaded = yaml.load(stream)
js = json.loads(sys.argv[1])
# Use update to not remove existing comments
data_loaded['colors']['primary'].update(js['colors']['primary'])
data_loaded['colors']['normal'].update(js['colors']['normal'])
data_loaded['colors']['bright'].update(js['colors']['bright'])
# Write alacritty config
with io.open(conf, 'w', encoding='utf8') as outfile:
yaml.dump(data_loaded, outfile)

View File

@ -367,6 +367,67 @@ apply_cygwin() {
echo "Done - please reopen your Cygwin terminal to see the changes" echo "Done - please reopen your Cygwin terminal to see the changes"
} }
apply_alacritty() {
# |
# | Applying values on Alacritty
# | ===========================================
json_str="\
{ \
\"colors\": \
{\
\"primary\":\
{\
\"background\": \"$BACKGROUND_COLOR\",\
\"foreground\": \"$FOREGROUND_COLOR\"\
},\
\"normal\":\
{\
\"black\": \"$COLOR_01\",\
\"red\": \"$COLOR_02\",\
\"green\": \"$COLOR_03\",\
\"yellow\":\"$COLOR_04\",\
\"blue\":\"$COLOR_05\",\
\"magenta\": \"$COLOR_06\",\
\"cyan\":\"$COLOR_07\",\
\"white\": \"$COLOR_08\"\
},\
\"bright\":\
{\
\"black\":\"$COLOR_09\",\
\"red\":\"$COLOR_10\",\
\"green\":\"$COLOR_11\",\
\"yellow\": \"$COLOR_12\",\
\"blue\": \"$COLOR_13\",\
\"magenta\":\"$COLOR_14\",\
\"cyan\": \"$COLOR_15\",\
\"white\":\"$COLOR_16\"\
} \
}\
}"
SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"
# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Mayccoll/Gogh/master"}
if [[ -e "${SCRIPT_PATH}/apply-alacritty.py" ]]; then
python3 "${SCRIPT_PATH}/apply-alacritty.py" "$json_str"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
python3 -c "$(curl -so- "${BASE_URL}/apply-alacritty.py")" "$json_str"
else
# Linux ships with wget
python3 -c "$(wget -qO- "${BASE_URL}/apply-alacritty.py")" "$json_str"
fi
fi
}
apply_darwin() { apply_darwin() {
# | # |
# | Applying values on iTerm2 # | Applying values on iTerm2
@ -713,6 +774,10 @@ case "${TERMINAL}" in
apply_xfce4-terminal apply_xfce4-terminal
;; ;;
alacritty )
apply_alacritty
;;
* ) * )
printf '%s\n' \ printf '%s\n' \
"Unsupported terminal!" \ "Unsupported terminal!" \