Fixed zellij loading

This commit is contained in:
Lockszmith (@wolfpack) 2024-12-03 08:20:29 -05:00
parent cdaca47780
commit 681ff45134
1 changed files with 36 additions and 24 deletions

View File

@ -15,37 +15,49 @@ BASE_SHELL=$(basename "$SHELL")
if is_sourced; then if is_sourced; then
zellij-cleanup() { zellij-cleanup() {
type -pa zellij > /dev/null && type -pa zellij | sed -Ee 's/^.* is //' | awk '{ print $1 }' | grep -E "^$HOME" | xargs -tr rm which zellij > /dev/null && which zellij | grep -E "^$HOME" | ${SUDO:-} xargs -tr rm
[[ -d "$HOME/.cache/zellij" ]] && echo "$HOME/.cache/zellij" | xargs -rt rm -fR [[ -d "$HOME/.cache/zellij" ]] && echo "$HOME/.cache/zellij" | ${SUDO:-} xargs -tr rm -fR
find /tmp -maxdepth 1 -mindepth 1 -type d -name 'zellij*' -print0 | xargs -r0t rm -fR find /tmp -maxdepth 1 -mindepth 1 -type d -name 'zellij*' -print0 | ${SUDO:-} xargs -r0t rm -fR
if [[ -d "$HOME/.cache/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' printf 'Zellij has been cleaned up, you can now reinstall it.\n'
unset zellij-cleanup
fi
} }
zellij() { refresh-zellij() {
if [[ ! -x ~/bin/zellij ]]; then if [ -z "$(which zellij)" ] && ! [ -x ~/.local/bin/zellij ]; then
if [[ -x $HOME/.cache/chezmoi/tmp/zellij/zellij ]]; then if [[ ! -r /tmp/zellij/bootstrap/zellij ]]; then
ln --symbolic --relative $HOME/.cache/chezmoi/tmp/zellij/zellij ~/bin
elif [[ ! -x /tmp/zellij/bootstrap/zellij ]]; then
printf "Grabbing zellij from the web!\n" printf "Grabbing zellij from the web!\n"
bash <(curl -sL zellij.dev/launch) "${@}" && return bash <(curl -sL zellij.dev/launch) "--help" > /dev/null 2>&1 || true
fi fi
fi if [[ -r /tmp/zellij/bootstrap/zellij ]]; then
if [[ -e /tmp/zellij/bootstrap/zellij ]]; then mv /tmp/zellij/bootstrap/zellij ~/.local/bin/zellij
mv /tmp/zellij/bootstrap/zellij ~/bin/zellij
rm -fR /tmp/zellij rm -fR /tmp/zellij
fi fi
if [[ -x ~/bin/zellij ]]; then
~/bin/zellij "${@}"
fi fi
refresh-zellij() { :; }
}
zellij() {
refresh-zellij
if [[ $# -eq 0 ]]; then
env zellij attach -c $USER@$(hostname)
else
env zellij "${@}"
fi
} }
zellij-completion() { zellij-completion() {
if [[ "${BASE_SHELL}" == "zsh" ]]; then if [[ "${BASE_SHELL}" == "zsh" ]]; then
. <( zellij setup --generate-completion zsh | sed -Ee 's/^(_(zellij) ).*/compdef \1\2/' ) . <( env zellij setup --generate-completion zsh | sed -Ee 's/^(_(zellij) ).*/compdef \1\2/' )
else else
. <( zellij setup --generate-completion "$BASE_SHELL" ) . <( env zellij setup --generate-completion "$BASE_SHELL" )
fi fi
} }
${SET:-:} -x
if [[ -n "$(which zellij)" ]]; then
zellij-completion zellij-completion
fi
${SET:-:} -x
# Was needed when zsh would load # Was needed when zsh would load
# . <( zellij setup --generate-completion "$BASE_SHELL" | sed -ne '/^function/,$p' ) # . <( zellij setup --generate-completion "$BASE_SHELL" | sed -ne '/^function/,$p' )
if [[ -z "$ZELLIJ_SESSION_NAME" ]]; then if [[ -z "$ZELLIJ_SESSION_NAME" ]]; then