How make tmux on start, create a couple of windows and start given programs in them?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How make tmux on start, create a couple of windows and start given programs in them?

Joseph Mayer
Hi,

I have one single command for starting and (re)attaching to tmux, and
it's "tmux -u new -t main". It works as it should.

On each fresh tmux start, tmux runs /etc/tmux.conf , and so I put some
general configuration in there like "set -g status-bg SOMECOLOR".

I'd now like tmux to create five windows on startup, and each window
should be running a particular program e.g. "top" in one window, "ksh"
in another, and so on.

How do I do this - is it possible to add as extra configuration in
"tmux.conf", or do I need to create a separate file ("mywindows.conf")
that I instruct tmux of via some other argument, or how?

And what should the commands be.


Of course creating the windows and starting the processes should happen
only at the initial "tmux -u new -t main" run which starts the first
tmux OS process, not on subsequent "tmux -u new -t main" calls which
reattach to the already existing tmux or add a concurrent terminal to
access the already existing tmux.

Thanks,
Joseph

Reply | Threaded
Open this post in threaded view
|

Re: How make tmux on start, create a couple of windows and start given programs in them?

Solene Rapenne
Joseph Mayer <[hidden email]> wrote:

> Hi,
>
> I have one single command for starting and (re)attaching to tmux, and
> it's "tmux -u new -t main". It works as it should.
>
> On each fresh tmux start, tmux runs /etc/tmux.conf , and so I put some
> general configuration in there like "set -g status-bg SOMECOLOR".
>
> I'd now like tmux to create five windows on startup, and each window
> should be running a particular program e.g. "top" in one window, "ksh"
> in another, and so on.
>
> How do I do this - is it possible to add as extra configuration in
> "tmux.conf", or do I need to create a separate file ("mywindows.conf")
> that I instruct tmux of via some other argument, or how?
>
> And what should the commands be.
>
>
> Of course creating the windows and starting the processes should happen
> only at the initial "tmux -u new -t main" run which starts the first
> tmux OS process, not on subsequent "tmux -u new -t main" calls which
> reattach to the already existing tmux or add a concurrent terminal to
> access the already existing tmux.
>
> Thanks,
> Joseph

Hello,

I use a script which create a named session, split the windows, choose a pane,
send keys to start a command, split again etc...

Here is my script:

#!/bin/sh
SESSION=tor
tmux -2 new-session -d -s $SESSION
tmux split-window -v
tmux select-pane -t 0
tmux send-keys "vnstat -l -ru" C-m
tmux split-window -h
tmux select-pane -t 1
tmux send-keys "while true ; do clear ; vnstat -ru -h ; sleep 120 ; done" C-m
tmux select-pane -t 2
tmux send-keys "systat rules" C-m
tmux attach

Reply | Threaded
Open this post in threaded view
|

Re: How make tmux on start, create a couple of windows and start given programs in them?

Nicholas Marriott-2
In reply to this post by Joseph Mayer
Hi

Put it in .tmux.conf including the new-session, and start tmux with
"tmux attach" or "tmux start". Or run a separate config file later with
"tmux source myconfig".


On Fri, Nov 02, 2018 at 02:44:40PM +0000, Joseph Mayer wrote:

> Hi,
>
> I have one single command for starting and (re)attaching to tmux, and
> it's "tmux -u new -t main". It works as it should.
>
> On each fresh tmux start, tmux runs /etc/tmux.conf , and so I put some
> general configuration in there like "set -g status-bg SOMECOLOR".
>
> I'd now like tmux to create five windows on startup, and each window
> should be running a particular program e.g. "top" in one window, "ksh"
> in another, and so on.
>
> How do I do this - is it possible to add as extra configuration in
> "tmux.conf", or do I need to create a separate file ("mywindows.conf")
> that I instruct tmux of via some other argument, or how?
>
> And what should the commands be.
>
>
> Of course creating the windows and starting the processes should happen
> only at the initial "tmux -u new -t main" run which starts the first
> tmux OS process, not on subsequent "tmux -u new -t main" calls which
> reattach to the already existing tmux or add a concurrent terminal to
> access the already existing tmux.
>
> Thanks,
> Joseph