Created
December 21, 2022 07:02
-
-
Save cybertramp/dbf82e883650ca24b416a8a79fef9ea9 to your computer and use it in GitHub Desktop.
bash: make tui with tmux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### | |
### This is tmux using sample. | |
### 2022.12.21 cybertramp([email protected]) | |
### | |
## PRECONFIG | |
COMMAND_TMUX=tmux | |
TMUX_NAME=runner | |
PANE0__INIT_CMD="df -h" | |
PANE1__INIT_CMD="sshpass -p a [email protected]" | |
PANE2__INIT_CMD="ls -al" | |
PANE3__INIT_CMD="ps -ef" | |
PANE4__INIT_CMD="whoami" | |
## Check tmux command is availavle. | |
if ! command -v $COMMAND_TMUX &> /dev/null | |
then | |
echo "<the_command> could not be found" | |
exit | |
fi | |
## tmux running check | |
if tmux info &> /dev/null; then | |
echo running | |
else | |
echo not running | |
fi | |
tmux new-session -s ${TMUX_NAME} -n test -d | |
tmux split-window -h -p 90 | |
tmux select-pane -t 1 | |
tmux split-window -v -p 50 | |
tmux select-pane -t 1 | |
tmux split-window -v -p 50 | |
tmux select-pane -t 3 | |
tmux split-window -v -p 50 | |
tmux select-pane -t 0 | |
## Set options | |
tmux set -g pane-border-status top | |
## Set Title | |
tmux select-pane -t 1 -T "SESSION 1" | |
tmux select-pane -t 2 -T "SESSION 2" | |
tmux select-pane -t 3 -T "SESSION 3" | |
tmux select-pane -t 4 -T "SESSION 4" | |
tmux set -g mouse on | |
## Send command to pane | |
tmux select-pane -t 0 | |
tmux send-keys "$PANE0__INIT_CMD" Enter | |
tmux select-pane -t 1 | |
tmux send-keys "$PANE1__INIT_CMD" Enter | |
tmux select-pane -t 2 | |
tmux send-keys "$PANE2__INIT_CMD" Enter | |
tmux select-pane -t 3 | |
tmux send-keys "$PANE3__INIT_CMD" Enter | |
tmux select-pane -t 4 | |
tmux send-keys "$PANE4__INIT_CMD" Enter | |
## Attach setup tmux | |
tmux attach -t ${TMUX_NAME} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment