0

I want to create development environment in docker and establish there tmux session where I can see 2 watch processes (frontend watch process and backend watch process).\

I can't seem to understand how to write bash script that will create tmux session with 2 panes with predefined commands.

I want to use tmux and not some kind of "virtual split log viewer" so I can restart process in each pane manually, because well sometimes we make mistakes in code that will just kill the build-watch process and it needs to be restarted.

Thank you in advance!

idchlife
  • 101
  • 2

1 Answers1

0

Here is one way to do this

tmux new -d -s my-session-name \; split-window -h ;\ 
tmux send-keys -t my-session-name.1 "here you can write any command for process that will attach to terminal and show output, like python manage.py runserver" ENTER
tmux send-keys -t my-session-name.2 "here you can write any command for process that will attach to terminal and show output, like python manage.py runserver" ENTER

# Use this to connect whenever you want 
tmux a -t my-session-name

In the end you will have tmux session with 2 panes and each pane will have process running and showing output.

To switch between panes use Ctrl-b o

NOTE: you see those numbers after my-session-name? Those are panes

Sometimes you gotta change those numbers from 1 and 2 to 0 and 1. Test it and if you see only last panes or no panes executing command - try to find numbers for your panes. I assume knowing people here can comment how to determine which pane will have which number.

For example on my host machine my panes are 1 and 2, and inside docker (debian) they are 0 and 1

idchlife
  • 101
  • 2