Manage zellij configuration via chezmoi init

This commit is contained in:
Lockszmith (VAST@MacBook) 2025-05-08 02:57:34 -04:00
parent 4e6da56adf
commit 5835cd53f0
5 changed files with 55 additions and 30 deletions

View File

@ -0,0 +1 @@
../../_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl

View File

@ -1 +0,0 @@
../../../_home/private_dot_local/bin/executable_zellij-mode.tmpl

View File

@ -0,0 +1,18 @@
#! /usr/bin/env bash
set -e
echo "Generating zellij/config.kdl.tmpl..."
is_cmd() { [[ -n "$(command -v "${1}")" ]] ; }
if is_cmd zellij; then
zellij setup --dump-config \
| sed -Ee '
s/^keybinds {/keybinds clear-defaults=true{/;
s/"Ctrl g"/{''{ list (dig "style" "zellij" "leader-modifer" "Alt" .) (dig "style" "zellij" "leader-key" "a" .) | join " " | quote }''}/g;
s/"Ctrl ([a-z])"/"{''{ dig "style" "zellij" "leader-modifer" "Alt" . }''} \1"/g;
s!^// theme "default"$!theme {''{ dig "style" "zellij" "theme" "default" . | quote }''}!
' \
> "$CHEZMOI_SOURCE_DIR/private_dot_config/zellij/config.kdl.tmpl"
fi

View File

@ -1,18 +0,0 @@
#! /usr/bin/env bash
BASE_0=${BASE_0:-$0}
BASE_SHELL="${BASE_SHELL:-$(basename "$SHELL")}"
BASE="config.kdl" ROOT=~/.config/zellij
SRC="${BASE}.${1:{{- dig "style" "zellij" "?Mode missing" . -}}}"
[[ -s "${ROOT}/${SRC}" ]] \
|| ( printf 'Mode "%s" must exists!\n' "${1}" >&2; return 1 )
[[ -L "${ROOT}/${BASE}" || ! -e "${ROOT}/${BASE}" ]] \
|| ( printf 'config.kdl is an actual file, will not replace\n' >&2; return 2 )
if [[ "$RESET" == 'reset' ]]; then
[[ -e "${ROOT}/${BASE}" ]] && rm "${ROOT}/${BASE}"
cp "${ROOT}/${SRC}" "${ROOT}/${BASE}"
else
(cd "${ROOT}"; ln -sf "${SRC}" "${BASE}")
fi

View File

@ -33,18 +33,32 @@
) ( list .chezmoi.username " (@" $sysname ")" | join ""
)) -}}
{{- $zellijStyle := "-normal" -}}
{{- if not (dig "style" "zellij" "" .) -}}
{{- $zellijStyle = dig "style" "zellij" $zellijStyle . -}}
{{- $zellijStyleChoices := list "-locked-full" "-locked" "-normal" -}}
{{- $zellijStyleSelected := promptMultichoice "Choose zellij style* (only first selection is chosen)" $zellijStyleChoices (list $zellijStyle) -}}
{{- $zellijStyle = first $zellijStyleSelected | default $zellijStyle -}}
{{/*{{- $zellijStyle := promptChoiceOnce . "style.zellij" "Zellij default style" $zellijStyleChoices "-locked-full" -}}*/}}
{{- end -}}
{{- $zellijLeaderModifier := list (dig "style" "zellij" "leader-modifier" "Alt" .) "dummy" | join " " | splitList " " -}}
{{- $zellijLeaderModifier = slice $zellijLeaderModifier 0 (sub (len $zellijLeaderModifier) 1) -}}
{{- $zellijLeaderModifierChoices := list "Alt" "Ctrl" -}}
{{- $zellijLeaderModifierSelected := promptMultichoice "Choose zellij Leader Modifyer" $zellijLeaderModifierChoices $zellijLeaderModifier -}}
{{- $zellijLeaderModifier = $zellijLeaderModifierSelected | join " " -}}
{{- $zellijLeaderKey := promptString "Choose zellij Leader Key" (dig "style" "zellij" "leader-key" "a" .) -}}
{{- $zellijFrames := dig "style" "zellij" "frames" "y" . -}}
{{- $zellijFrames = promptChoice "Should zellij show pane frames? (y/n)" (list "y" "n" ) $zellijFrames -}}
{{- $zellijTheme := dig "style" "zellij" "theme" "default" . -}}
{{- $zellijThemeChoices := list "default"
"ansi" "ao" "atelier-sulphurpool" "ayu_mirage" "ayu_dark"
"catppuccin-frappe" "catppuccin-macchiato" "cyber-noir" "blade-runner"
"retro-wave" "dracula" "everforest-dark" "gruvbox-dark" "iceberg-dark"
"kanagawa" "lucario" "menace" "molokai-dark" "night-owl" "nightfox"
"nord" "one-half-dark" "onedark" "solarized-dark" "tokyo-night-dark"
"tokyo-night-storm" "tokyo-night" "vesper"
-}}
{{- $zellijThemeSelected := promptMultichoice (list "Choose zellij theme *(only first selection is chose - default is '" $zellijTheme "')" | join "") $zellijThemeChoices -}}
{{- $zellijTheme = first $zellijThemeSelected | default $zellijTheme -}}
{{- $promptStyle := dig "style" "prompt" "cool" . -}}
{{- $promptStyleChoices := list "cool" "hot" "lux" -}}
{{- $promptStyleSelected := promptMultichoice (list "Choose prompt style* (only first selection is chose - default is '" $promptStyle "')" | join "") $promptStyleChoices -}}
{{- $promptStyleSelected := promptMultichoice (list "Choose prompt style *(only first selection is chose - default is '" $promptStyle "')" | join "") $promptStyleChoices -}}
{{- $promptStyle = first $promptStyleSelected | default $promptStyle -}}
{{/*{{- $promptStyle = promptChoice "Prompt style" $promptStyleChoices $promptStyle -}}*/}}
@ -128,8 +142,19 @@ scriptTempDir={{ $scriptTempDir | quote }}
{{- if ($promptStyle) }}
prompt={{- $promptStyle | quote }}
{{- end }}
{{- if ($zellijStyle) }}
zellij={{- $zellijStyle | quote }}
[data.style.zellij]
{{- if ($zellijFrames) }}
frames={{- $zellijFrames | quote }}
{{- end }}
{{- if ($zellijTheme) }}
theme={{- $zellijTheme | quote }}
{{- end }}
{{- if ($zellijLeaderModifier) }}
leader-modifier={{- $zellijLeaderModifier | quote }}
{{- end }}
{{- if ($zellijLeaderKey) }}
leader-key={{- $zellijLeaderKey | quote }}
{{- end }}
[diff]