From 5835cd53f0cadca4daa1c1e517198035843929e0 Mon Sep 17 00:00:00 2001 From: "Lockszmith (VAST@MacBook)" Date: Thu, 8 May 2025 02:57:34 -0400 Subject: [PATCH] Manage zellij configuration via chezmoi init --- ...e_before_update_zellij.config.default.tmpl | 1 + .../bin/executable_zellij-mode.tmpl | 1 - ...e_before_update_zellij.config.default.tmpl | 18 +++++++ .../bin/executable_zellij-mode.tmpl | 18 ------- chezmoi.roots/_src.all/.chezmoi.toml.tmpl | 47 ++++++++++++++----- 5 files changed, 55 insertions(+), 30 deletions(-) create mode 120000 chezmoi.roots/_home.macos/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl delete mode 120000 chezmoi.roots/_home.macos/private_dot_local/bin/executable_zellij-mode.tmpl create mode 100755 chezmoi.roots/_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl delete mode 100644 chezmoi.roots/_home/private_dot_local/bin/executable_zellij-mode.tmpl diff --git a/chezmoi.roots/_home.macos/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl b/chezmoi.roots/_home.macos/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl new file mode 120000 index 0000000..caf83b6 --- /dev/null +++ b/chezmoi.roots/_home.macos/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl @@ -0,0 +1 @@ +../../_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl \ No newline at end of file diff --git a/chezmoi.roots/_home.macos/private_dot_local/bin/executable_zellij-mode.tmpl b/chezmoi.roots/_home.macos/private_dot_local/bin/executable_zellij-mode.tmpl deleted file mode 120000 index 2d5be41..0000000 --- a/chezmoi.roots/_home.macos/private_dot_local/bin/executable_zellij-mode.tmpl +++ /dev/null @@ -1 +0,0 @@ -../../../_home/private_dot_local/bin/executable_zellij-mode.tmpl \ No newline at end of file diff --git a/chezmoi.roots/_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl b/chezmoi.roots/_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl new file mode 100755 index 0000000..9cb38d0 --- /dev/null +++ b/chezmoi.roots/_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl @@ -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 + diff --git a/chezmoi.roots/_home/private_dot_local/bin/executable_zellij-mode.tmpl b/chezmoi.roots/_home/private_dot_local/bin/executable_zellij-mode.tmpl deleted file mode 100644 index 364717f..0000000 --- a/chezmoi.roots/_home/private_dot_local/bin/executable_zellij-mode.tmpl +++ /dev/null @@ -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 - diff --git a/chezmoi.roots/_src.all/.chezmoi.toml.tmpl b/chezmoi.roots/_src.all/.chezmoi.toml.tmpl index fba2cb3..7ec4f42 100644 --- a/chezmoi.roots/_src.all/.chezmoi.toml.tmpl +++ b/chezmoi.roots/_src.all/.chezmoi.toml.tmpl @@ -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]