Skip to content

Instantly share code, notes, and snippets.

@niderhoff
Created April 9, 2018 13:45
Show Gist options
  • Save niderhoff/871d953bcf14ab6814255a1ab4b6ab34 to your computer and use it in GitHub Desktop.
Save niderhoff/871d953bcf14ab6814255a1ab4b6ab34 to your computer and use it in GitHub Desktop.
create multiple tmux panes from bash script
#!/bin/bash
SESSIONNAME="niid"
STARTDIR="/home/niid/Documents/Projects"
tmux has-session -t apr &> /dev/null
if [ $? != 0 ]
then
tmux new-session -s $SESSIONNAME -c $STARTDIR/TCM -n "jptr" -d
tmux send-keys -t $SESSIONNAME:0 "source activate TCM" C-m
tmux send-keys -t $SESSIONNAME:0 "CUDA_VISIBLE_DEVICES=1 jupyter notebook --allow-root" C-m
tmux split-window -t $SESSIONNAME:0 -v -c $STARTDIR/TCM
tmux send-keys -t $SESSIONNAME:0 "source activate TCM" C-m
tmux new-window -t $SESSIONNAME:1 -n "vitals" "htop"
tmux split-window -t $SESSIONNAME:1 -v "watch -n 2 nvidia-smi"
tmux new-window -t $SESSIONNAME:2 -n "KISHOW" -c $STARTDIR/kishow
tmux send-keys -t $SESSIONNAME:2 "source activate kishow" C-m
tmux split-window -t $SESSIONNAME:2 -v -c $STARTDIR/kishow
tmux send-keys -t $SESSIONNAME:2 "source activate kishow" C-m
tmux split-window -t $SESSIONNAME:2 -v -c $STARTDIR/kishow
tmux send-keys -t $SESSIONNAME:2 "source activate kishow" C-m
fi
tmux select-window -t $SESSIONNAME:0
tmux attach -t $SESSIONNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment