Manage zellij configuration via chezmoi init
This commit is contained in:
parent
4e6da56adf
commit
5835cd53f0
5 changed files with 55 additions and 30 deletions
chezmoi.roots/_home
.chezmoiscripts
private_dot_local/bin
|
@ -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
|
||||
|
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue