Monday, January 29, 2024

Tmux startup script tempalte

 Tmux script template

#!/bin/bash

SESSION_NAME=dev

# new-session -c start-directory -n window-name -s session-name -t group-name -x width -y height [shell-command]
tmux has-session -t ${SESSION_NAME} 2>&1 >/dev/null

#if [ $? -ne 0 ];then
#	source /opt/.../export.sh
#	tmux new-session -s $SESSION_NAME -n main -d
#	tmux new-window  -c $SRC_DIR -n editor
#	tmux new-window  -c $BUILD_DIR -n build
#	tmux attach -t $SESSION_NAME
#	tmux select-windows -t $SESSION_NAME:0
#else
#	echo "Session is already started"
#fi
#

if [ $? -ne 0 ]; then
    # create new session
    tmux new-session -s ${SESSION_NAME} -n main -d
    tmux split-window -h
    tmux split-window -v
    tmux attach -t ${SESSION_NAME}
else
    echo "Tmux session is already created. Use 'tmux attach -t SESSION_NAME'"
fi

No comments: