Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for attaching to group sessions #806

Open
hamidb opened this issue Feb 10, 2021 · 2 comments
Open

Support for attaching to group sessions #806

hamidb opened this issue Feb 10, 2021 · 2 comments

Comments

@hamidb
Copy link

hamidb commented Feb 10, 2021

Hello,
I am not sure if tmuxinator can handle group sessions. So I decided to open this issue.
From my understanding, tmuxinator comes short in automating something like this:

$ tmux new-session -s main
$ In "main", apply rules and layouts defined in main.yml

Now, in another terminal, connect to that existing window group:

$ tmux new-session -t main -s child
$ In "child", create a new window and apply some rules and layout.

I know we can use on_project_exit and attach: false field in the yml file but I could not reproduce the above behaviour with them.

@fritzr
Copy link

fritzr commented Mar 10, 2021

I was able to use tmux session groups by manually creating the session group using on_project_first_start.

In the main.yml file, use on_project_first_start to initialize the session with a group name:

# ~/.config/tmuxinator/main.yml
# ...
# Run on project start, the first time
on_project_first_start: tmux new-session -d -s main -t main
# ...
# define your layout here
windows:
  - xyz: # ...

Now tmuxinator start main will create the session with a group. You will get a warning duplicate session: main but everything will still work.

Then make a child.yml with a similar on_project_first_start:

# ~/.config/tmuxinator/child.yml
# ...
# Run on project start, the first time
on_project_first_start: tmux new-session -d -s child -t main
# ..
# dummy window layout here, not actually used, but needed for config to be valid
windows:
  - dummy: false

With this setup you can do:

$ tmuxinator start main
duplicate session: main
$ tmuxinator start child
duplicate session: child

# now you have two sessions that share windows:
$ tmux attach-session -t main
# elsewhere:
$ tmux attach-session -t child

Perhaps a small patch to tmuxinator would make this easier. It shouldn't be that hard to add a group: key in the yaml file, or perhaps a -g option in the CLI.

@chreniuc
Copy link

Any news on this? I'm also interested in this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants