Created
March 14, 2019 19:11
-
-
Save jeffesp/810376ca0f25c9b8fdfdae933df3535a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCHEME_DIR=${XDG_CONFIG_HOME:-~/.config}/calico | |
_create_config_dir() { | |
if [[ ! -d $SCHEME_DIR ]]; then | |
mkdir -p $SCHEME_DIR | |
fi | |
} | |
get_schemes() { | |
basename -s ".colors" $(ls $SCHEME_DIR) | |
} | |
new_scheme() { | |
_create_config_dir | |
FILE="$SCHEME_DIR/$1.colors" | |
touch $FILE | |
kitty @ get-colors > $FILE | |
} | |
edit_scheme() { | |
_create_config_dir | |
FILE="$SCHEME_DIR/$1.colors" | |
exec /usr/bin/editor $FILE | |
} | |
set_scheme() { | |
FILE="$SCHEME_DIR/$1.colors" | |
if [[ ! -e $FILE ]]; then | |
echo "$1 scheme does has not been defined" | |
exit -1 | |
fi | |
kitty @ set-colors --all --configured $FILE | |
} | |
reset_scheme() { | |
kitty @ set-colors --reset | |
} | |
case "$1" in | |
list) | |
get_schemes | |
;; | |
new) | |
new_scheme $2 | |
;; | |
edit) | |
edit_scheme $2 | |
;; | |
reset) | |
reset_scheme | |
;; | |
activate) | |
set_scheme $2 | |
;; | |
*) | |
if [[ -z $1 ]]; then | |
echo "Usage: $0 list|[activate] <scheme-name>|new <scheme-name>|edit <scheme-name|reset" | |
exit -1 | |
fi | |
set_scheme $1 | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment