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 deleted file mode 120000 index caf83b6..0000000 --- a/chezmoi.roots/_home.macos/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl +++ /dev/null @@ -1 +0,0 @@ -../../_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 new file mode 120000 index 0000000..2d5be41 --- /dev/null +++ b/chezmoi.roots/_home.macos/private_dot_local/bin/executable_zellij-mode.tmpl @@ -0,0 +1 @@ +../../../_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 deleted file mode 100755 index 9cb38d0..0000000 --- a/chezmoi.roots/_home/.chezmoiscripts/run_onchange_before_update_zellij.config.default.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -#! /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_load-zellij b/chezmoi.roots/_home/private_dot_local/bin/executable_load-zellij index 9df778a..1286afb 100644 --- a/chezmoi.roots/_home/private_dot_local/bin/executable_load-zellij +++ b/chezmoi.roots/_home/private_dot_local/bin/executable_load-zellij @@ -16,14 +16,12 @@ 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 - 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 + [[ -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 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' 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 new file mode 100644 index 0000000..364717f --- /dev/null +++ b/chezmoi.roots/_home/private_dot_local/bin/executable_zellij-mode.tmpl @@ -0,0 +1,18 @@ +#! /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 7ec4f42..fba2cb3 100644 --- a/chezmoi.roots/_src.all/.chezmoi.toml.tmpl +++ b/chezmoi.roots/_src.all/.chezmoi.toml.tmpl @@ -33,32 +33,18 @@ ) ( list .chezmoi.username " (@" $sysname ")" | join "" )) -}} -{{- $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 -}} +{{- $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 -}} {{- $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 -}}*/}} @@ -142,19 +128,8 @@ scriptTempDir={{ $scriptTempDir | quote }} {{- if ($promptStyle) }} prompt={{- $promptStyle | quote }} {{- end }} - -[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 }} +{{- if ($zellijStyle) }} + zellij={{- $zellijStyle | quote }} {{- end }} [diff]