Added tmix function

This commit is contained in:
Christian Baer 2020-07-04 09:14:39 +02:00
parent 088dea8fd4
commit 989ea0c20e
2 changed files with 31 additions and 0 deletions

30
.zsh/functions/tmix Normal file
View File

@ -0,0 +1,30 @@
function tmix () {
set -o shwordsplit
SESSION="${TMIX_SESSION:-TMIX}"
SERVERS="${TMIX_SERVERS}"
if [[ $1 == "kill" ]]; then
echo "Killing tmux session $SESSION"
tmux kill-session -t "${SESSION}"
else
if [ -z "$SERVERS" ]; then
# display usage if no parameters given
echo "Usage: tmix"
echo "No servers configured. define them as TMIX_SERVERS=\"<SERVER> <SERVER> <SERVER>\" e.g. in ${ZDOTDIR}/lib/30-extras.zsh"
exit
else
echo "Creating tmux session $SESSION"
tmux new-session -d -s "${SESSION}"
create_session=$?
if [[ $create_session = 0 ]]; then
for SERVER in ${SERVERS}; do
echo ">>> Connecting to ${SERVER}"
tmux new-window -n ${SERVER} -t ${SESSION}:
tmux send-keys -t ${SESSION}:${SERVER} "/usr/local/bin/mosh ${SERVER} -- doas tmux a -d" C-m
done
fi
fi
fi
}

View File

@ -2,3 +2,4 @@ fpath=($fpath $ZDOTDIR/functions)
autoload extract
autoload img2iso
autoload tmix