[LINUX] Restore and automate multiple panes of your favorite tmux and vim sessions

Development work on the Mac or Linux terminal multiplexer tmux is automated by opening multiple panes and windows, as the same work occurs each time.

Go to the project path and restore the session to the top pane of tmux as soon as you launch vim and into the bottom pane of tmux This is a batch file that displays the calendar.

Contents of automation batch file

$ cat project.sh
#!/bin/bash

#Working directory full pathname
WORK_DIR="$HOME/project/"
#Session name
SESSION="project01"
#Window name
WINDOW="main_window"
tmux new-session -d  -s $SESSION -n $WINDOW -c $WORK_DIR
#tmux split-window -h -c "$DIR"
tmux split-window -v -c "$DIR"
#Resize bottom pane
tmux resize-pane -D 5
#Go to pane 0
tmux select-pane -t 0
#Resume vim session
tmux send-keys -t 0.0  'vim -S Session.vim' C-m
#Execution of cal command
tmux send-keys -t 0.1  'cal' C-m
#Attach by specifying the session name
tmux attach -t $SESSION

How to execute a batch

$ bash project.sh

Display result of terminal multiplexer tmux

tmux_vim_cal_20200602_135846.png

Check tmux version

$ tmux -V
tmux 3.1b

Recommended Posts

Restore and automate multiple panes of your favorite tmux and vim sessions