Add zellij attach helper

This commit is contained in:
Daniel Lynn 2023-04-11 15:53:57 -05:00
parent bf741014c2
commit 0eb7102c7e
Signed by: daniel
GPG Key ID: 655C07B9B3DDC88B

View File

@ -3,6 +3,21 @@ if (( $+commands[zellij] )); then
ZELLIJ_AUTO_ATTACH=true
eval "$(zellij setup --generate-auto-start zsh)"
if (( $+commands[sk] )); then
za() {
local zj_sessions=$(zellij list-sessions)
local no_sessions=$(echo "${zj_sessions}" | wc -l)
if [ "${no_sessions}" -ge 2 ]; then
zellij attach \
"$(echo "${zj_sessions}" | sk)"
else
zellij attach -c
fi
}
fi
ide() {
local layout="${ZELLIJ_LAYOUT:-${HOME}/.config/zellij/layouts/project.kdl}"
local name="${PWD##*/}"
@ -12,7 +27,7 @@ if (( $+commands[zellij] )); then
# FIXME: https://github.com/zellij-org/zellij/issues/2299
zellij action new-tab --layout "${layout}" --cwd "${PWD}" --name "${name}"
else
zellij --layout "${layout}" $@
zellij --layout "${layout}" --session "${name}"
fi
}
fi