-
Notifications
You must be signed in to change notification settings - Fork 35
Example: always create a shpool session when using SSH
thiswillbeyourgithub edited this page Jun 19, 2024
·
4 revisions
@thiswillbeyourgithub shared an example showing how to create a new shpool session on ssh login:
## directly checks if it should start a tmux session to avoir running the entire zshrc twice
if [[ "$ZSH_ARGZERO" == *"zsh" ]] # don't create a shpool is an argument was given to zsh
then
# create a new shpool session
$(printenv | grep -q '^SHPOOL_SESSION_NAME=') || { # if we're not already in a shpool session
{
sessions=$(shpool list | tail -n +2 | cut -f1)
for letter in {a..z} # sessions are named a through z to be easy to type on termux, as shpool has no autocomplete
do
$(echo "$sessions" | grep -q "$letter") || {
# notify-send "Creating shpool session $letter"
shpool attach "$letter" || notify-send "Error creating shpool session"
break # we could logout here too
}
done
} || { notify-send -u critical "Error creating shpool session" ; echo "Error creating shpool session" }
}
$(printenv | grep -q '^SHPOOL_SESSION_NAME=') && {
echo "Using shpool session $SHPOOL_SESSION_NAME"
}
fi