For example: start new tmux session, launch webserver (sends log into console), and launch second tmux window for editor.
I had trying do this by different ways - but nothing works.
On
You can run shell commands from ~/.tmux.conf:
if-shell shell-command export I_AM_USING_TMUX=1
But it often does not seem to work as expected...
The environment variable TMUX is set when you run tmux. Then you can conditionally run shell commands from ~/.bash_profile:
if [[ ! -z "$TMUX" ]]; then
# run shell commands
fi
Or, you can export your own environment variable from ~/.tmux.conf file (as I already exported one from the beginning) and use it for if condition from ~/.bash_profile again:
if [[ ! -z "$GHCHOI_IS_USING_TMUX" ]]; then
# run shell commands
fi
On
For commands executions, take a look at this answer.
But you can also predefining layouts of tmux sessions, try tmuxinator/tmuxinator .
Take a look at tmuxify (disclaimer: I wrote it).
It's to automate the launch of
tmuxsessions by defining a layout file with windows, panes and commands.