diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-23 12:28:38 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-23 12:30:14 +0100 |
commit | c7faac3480d2c52db7e952f638f7f162fb98eeec (patch) | |
tree | 32d112a9532bcf8391a47384b91f6ef4c729e88a /.local/share/mode/plug.d | |
parent | 95db61081c2555c069c3287fd30d9c8a1757acb1 (diff) |
`mode` update
Diffstat (limited to '.local/share/mode/plug.d')
-rw-r--r-- | .local/share/mode/plug.d/10_lib | 31 | ||||
-rw-r--r-- | .local/share/mode/plug.d/20_export_colors | 2 | ||||
-rw-r--r-- | .local/share/mode/plug.d/20_export_mode | 2 | ||||
-rw-r--r-- | .local/share/mode/plug.d/20_export_vim_theme | 2 | ||||
-rw-r--r-- | .local/share/mode/plug.d/50_accent | 17 |
5 files changed, 42 insertions, 12 deletions
diff --git a/.local/share/mode/plug.d/10_lib b/.local/share/mode/plug.d/10_lib index 61817bc..abe75b1 100644 --- a/.local/share/mode/plug.d/10_lib +++ b/.local/share/mode/plug.d/10_lib @@ -1,5 +1,36 @@ #!/bin/sh # utility library functions hex_to_rgb_array() { pastel format rgb "$1" | cut -c4- | tr '()' '[]' ; } + mix_rgb() { pastel mix --colorspace=RGB --fraction="$3" "$1" "$2" | pastel format hex ; } +getvar() { + key="$1" + eval "printf '%s' \"\$$key\"" +} + +setvar() { + key="$1" + value="$2" + eval "$key='$(printf '%s' "$value")'" +} + +themevar() { + key="$1" + if [ $# -eq 1 ] ; then + value="$(getvar "$key")" + else + value="$2" + setvar "$key" "$value" + fi + + vars="$vars +$(printf "export %s='%s'" "$key" "$value")" + eval "export $key" +} + +mkcd() { + mkdir -p "$1" + cd "$1" +} + diff --git a/.local/share/mode/plug.d/20_export_colors b/.local/share/mode/plug.d/20_export_colors index 017446d..0f53d1f 100644 --- a/.local/share/mode/plug.d/20_export_colors +++ b/.local/share/mode/plug.d/20_export_colors @@ -9,7 +9,7 @@ check_color() { echo "error: color $1 is not properly formatted (#RRGGBB)" stupid && exit 1 fi - eval "export $1" + themevar "$1" } for color in $(seq 0 15 | sed 's/^/color/') bg fg ; do check_color $color diff --git a/.local/share/mode/plug.d/20_export_mode b/.local/share/mode/plug.d/20_export_mode index 78432b6..c82c4e1 100644 --- a/.local/share/mode/plug.d/20_export_mode +++ b/.local/share/mode/plug.d/20_export_mode @@ -5,5 +5,5 @@ if [ "$mode" != 'dark' ] && [ "$mode" != 'light' ] ; then [ $? -eq 0 ] && mode=dark || mode=light echo "warn: theme $theme did not define \$mode as \"light\" or \"dark\", guessed $mode" >&2 fi -export mode +themevar mode diff --git a/.local/share/mode/plug.d/20_export_vim_theme b/.local/share/mode/plug.d/20_export_vim_theme index be76b8b..12304f3 100644 --- a/.local/share/mode/plug.d/20_export_vim_theme +++ b/.local/share/mode/plug.d/20_export_vim_theme @@ -3,4 +3,4 @@ if [ "$(find "$XDG_CONFIG_HOME/nvim" -name "$vim_theme_name.vim" | wc -l)" -eq 0 ] ; then echo "warn: vim theme $vim_theme_name does not appear to be installed" >&2 fi -export vim_theme_name +themevar vim_theme_name diff --git a/.local/share/mode/plug.d/50_accent b/.local/share/mode/plug.d/50_accent index 2a8a113..ceb3209 100644 --- a/.local/share/mode/plug.d/50_accent +++ b/.local/share/mode/plug.d/50_accent @@ -4,13 +4,12 @@ # do not generate accent color if already explicitly defined by theme [ -n "$accent" ] && return -[ "$mode" = "light" ] && { - accent="$color15" - accent_text="$color0" -} -[ "$mode" = "dark" ] && { - accent="$(mix_rgb $bg $color0 0.5)" - accent_text="$fg" -} +if [ "$mode" = "light" ] ; then + themevar accent "$color15" + themevar accent_text "$color0" +fi +if [ "$mode" = "dark" ] ; then + themevar accent "$(mix_rgb $bg $color0 0.5)" + themevar accent_text "$fg" +fi -export accent accent_text |