Add Zellij mode switching/refreshing with zellij-mode

This commit is contained in:
Lockszmith (VAST@MacBook) 2025-04-17 18:22:34 -04:00
parent a546290cf6
commit 68d5d29274
1 changed files with 15 additions and 0 deletions

View File

@ -66,6 +66,21 @@ ${SET_X-:} -x
. <( env zellij setup --generate-completion "$BASE_SHELL" )
fi
}
zellij-mode() {
local BASE="config.kdl" ROOT=~/.config/zellij
local SRC="${BASE}.${1:?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
}
${SET_X-:} -x
if [[ -n "$(env which zellij)" ]]; then
zellij-load-completion