Compare commits

..

2 commits

Author SHA1 Message Date
Lockszmith (VAST@MacBook)
fe3bbd672e improved zellij cleanup 2025-05-08 02:58:34 -04:00
Lockszmith (VAST@MacBook)
5835cd53f0 Manage zellij configuration via chezmoi init 2025-05-08 02:57:34 -04:00
6 changed files with 63 additions and 36 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

@ -16,12 +16,14 @@ BASE_SHELL="${BASE_SHELL:-$(basename "$SHELL")}"
if is_sourced; then
zellij-cleanup() {
env which zellij > /dev/null && command -v zellij | grep -E "^$HOME" | ${SUDO:-} xargs -tr rm
[[ -d "$HOME/.cache/zellij" ]] \
&& ${SUDO:-} rm -fR "$HOME/.cache/zellij"
[[ -d "$HOME/Library/Caches/org.Zellij-Contributors.Zellij" ]] \
&& ${SUDO:-} rm -fR "$HOME/Library/Caches/org.Zellij-Contributors.Zellij"
find ${TMPDIR:-/tmp} -maxdepth 1 -mindepth 1 -type d -name 'zellij*' -print0 | ${SUDO:-} xargs -r0t rm -fR
if [[ -d "$HOME/.cache/zellij" || -d "$HOME/Library/Caches/org.Zellij-Contributors.Zellij" ]]; then
local _cache_dirs=("$HOME/.cache" "$HOME/Library/Caches/" "${TMPDIR}" "/tmp")
for cache_dir in "${_cache_dirs[@]}"; do
[[ -n "$cache_dir" && -d "$cache_dir" ]] || continue
find "$cache_dir" -maxdepth 1 -mindepth 1 -type d -iname '*zellij*' -print0 | ${SUDO:-} xargs -r0t rm -fR
done
if [[ "$(find "$cache_dir" -maxdepth 1 -mindepth 1 -type d -iname '*zellij*' | wc -l)" -gt 0 ]]; then
printf 'Zellij cleanup failed to remove the cache directory, you might still have a zellij session active.\n'
else
printf 'Zellij has been cleaned up, you can now reinstall it.\n'

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]