zellij with modes
This commit is contained in:
parent
df8e3cce67
commit
f67c062d5d
11 changed files with 1467 additions and 3 deletions
|
@ -0,0 +1,29 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
KEYBIND="${1:-Ctrl g}"
|
||||
NEWKEYBIND="${2:-${KEYBIND}}"
|
||||
|
||||
set -e
|
||||
|
||||
SRC_BASE=~/.config/zellij/config.kdl
|
||||
SRC=${SRC_BASE}.default
|
||||
[ -r "$SRC" ] || mv ~/.config/zellij/config.kdl ~/.config/zellij/config.kdl.default
|
||||
[ ! -e "$SRC_BASE" ] || rm "$SRC_BASE"
|
||||
|
||||
[ -r "$SRC" ] && < "$SRC" sed -Ee '
|
||||
/^[[:space:]]+tmux \{/,/^[[:space:]]+\{/ {
|
||||
d
|
||||
}' \
|
||||
| sed -Ee '
|
||||
s/bind "'"${KEYBIND}"'"/bind "'"${NEWKEYBIND}"'"/;
|
||||
s/(shared_except .* )"tmux" /\1/;
|
||||
s/(shared_except "locked")/\1 "tmux"/;
|
||||
s/shared {/shared_except "tmux" {/;
|
||||
s/("prompt") "tmux" {/\1 {/;
|
||||
s/([[:space:]]+)(pane {)/\1tmux {\n\1\1bind "'"${NEWKEYBIND}"'" { SwitchToMode "locked"; }\n\1}\n\1normal {\n\1\1bind "'"${NEWKEYBIND}"'" { SwitchToMode "tmux"; }\n\1}\n\1\2/;
|
||||
' > ~/.config/zellij/config.kdl.locked
|
||||
|
||||
LNOPT="-s"
|
||||
[ "$(uname)" = "Darwin" ] || LNOPT="${LNOPT}r"
|
||||
ln ${LNOPT} ~/.config/zellij/config.kdl.locked ~/.config/zellij/config.kdl
|
||||
|
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue