Added tmix function
This commit is contained in:
parent
088dea8fd4
commit
989ea0c20e
30
.zsh/functions/tmix
Normal file
30
.zsh/functions/tmix
Normal 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
|
||||||
|
}
|
@ -2,3 +2,4 @@ fpath=($fpath $ZDOTDIR/functions)
|
|||||||
|
|
||||||
autoload extract
|
autoload extract
|
||||||
autoload img2iso
|
autoload img2iso
|
||||||
|
autoload tmix
|
||||||
|
Loading…
Reference in New Issue
Block a user