Search code examples
tmux

How to create a copy of a tmux session?


I created a tmux session named template, in which I did some hard configurations, which are not scriptable due to manually typed passwords that can't be in plain-text files for security reasons.

Now I need to do independent tasks in that configured environment, so my idea is to create N independent copies of the template session, one for each new task as needed. I would like to do something like:

tmux copy-session -t template -s task_1
tmux copy-session -t template -s task_2
...
tmux copy-session -t template -s task_N

So I won't need to repeat that hard configuration for every task.

Is there any way to do that?


Solution

  • The solution that works for my case is to open a new terminal, do all the configurations in there, export relevant environment variables, and then start tmux, which will inherit the parent environment. Inside tmux I create one window for each task; each window will start with the configured settings.