tmux-python / tmuxp

🖥️ Session manager for tmux, build on libtmux.
https://tmuxp.git-pull.com/
MIT License
4.05k stars 231 forks source link

Unable to append more windows to existing session #674

Open bedge opened 3 years ago

bedge commented 3 years ago

I want to have a session names "envs" that I hang multiple windows off of, each with a few panes to connect to an target env.

Each time I run tmuxp load -y /Users/edgeb1/.tmux/<env filename> I expect to get a new window added to the same session.

Here's a snippet of the yaml for env1:

session_name: envs

windows:
- window_name: env1
  layout: tiled
  panes:
    - shell_command:
...

and repeated again for env2:

session_name: envs

windows:
- window_name: env2
  layout: tiled
  panes:
    - shell_command:
...

Identical, except for the window_name.

Such that my session tree should look like:

(0)   + a-local: 8 windows
(1)   - envs:
(2)   ├─> + 0: env1 (2 panes)
(3)   ├─>   1: env2 (2 panes) "~"

"a-local" is the default session.

I load these using:

tmuxp load -y /Users/edgeb1/.tmux/env1.yml tmuxp load -y /Users/edgeb1/.tmux/env2.yml

But what happens is that only the 1st one loads.

Afterwards I have this:

(0)   + a-local: 8 windows
(1)   - envs:
(2)   ├─> + 0: env1 (2 panes)

Or, if I reverse the order of the commands and instead run:

tmuxp load -y /Users/edgeb1/.tmux/env2.yml tmuxp load -y /Users/edgeb1/.tmux/env1.yml

Then I get this:

(0)   + a-local: 8 windows
(1)   - envs:
(2)   ├─> + 0: env2 (2 panes)

Same applies if I try load to yml files on the same cmdline:

[I] ➜ tmuxp load -y /Users/edgeb1/.tmux/env1.yml /Users/edgeb1/.tmux/env2.yml
[Loading] /Users/edgeb1/.tmux/env1.yml
Session created in detached state.
[Loading] /Users/edgeb1/.tmux/env2.yml

Note that this does work if I specify a unique session name for each yml:

session_name: env1

windows:
- window_name: env1
  layout: tiled
  panes:
    - shell_command:
...

and repeated again for env2:

session_name: env2

windows:
- window_name: env2
  layout: tiled
  panes:
    - shell_command:
...

Then I get:

(0)  + a-local: 8 windows
(1)  + nghc: 15 windows
(2)  - env1: 1 windows
(3)  └─> + 0: env1* (6 panes)
(4)  - env2: 1 windows (attached)
(5)  └─> + 0: env2*Z (6 panes)

AFAICT, I should be able to load additional yml configs that append new windows to an existing session.

It does "something" on the 2nd failed load is it always switches to the "envs" session, and shows the one window that's there.

I would expect to be able to load the same yml, say env1, over and over and keep getting new windows with the same name:

(0)  + a-local: 8 windows
(1)  + nghc: 15 windows
(2)  - env1: 1 windows
(3)  └─> + 0: env1* (6 panes)
(4)  └─> + 0: env1* (6 panes)
(5)  └─> + 0: env1* (6 panes)

but that doesn't work either. I can see the argument for not allowing duplicate session/window name instances, but the with unique window names it should work.

Step 2: Provide tmuxp details

tmux windows: 0: nghcZ (2 panes) [198x58] [layout 2148,198x58,0,0{99x58,0,0,8,98x58,100,0,58}] @8 1: zsh (1 panes) [198x58] [layout e991,198x58,0,0,60] @32 2: tess (1 panes) [198x58] [layout 698f,198x58,0,0,10] @10 3: git* (1 panes) [198x58] [layout 6990,198x58,0,0,11] @11 (active) 4: sb (1 panes) [198x58] [layout 6991,198x58,0,0,12] @12 5: sb2 (1 panes) [198x58] [layout 6992,198x58,0,0,13] @13 6: sb3 (1 panes) [198x58] [layout 6993,198x58,0,0,14] @14 7: dev (1 panes) [198x58] [layout 6994,198x58,0,0,15] @15 8: dev3 (1 panes) [198x58] [layout 6995,198x58,0,0,16] @16 9: dev4 (1 panes) [198x58] [layout 6996,198x58,0,0,17] @17 10: prd2 (1 panes) [198x58] [layout 6997,198x58,0,0,18] @18 11: prd5x (1 panes) [198x58] [layout 6998,198x58,0,0,19] @19 12: vnv5x (1 panes) [198x58] [layout e98f,198x58,0,0,20] @20 13: jk (1 panes) [198x58] [layout e990,198x58,0,0,21] @21 14: zsh- (2 panes) [198x58] [layout e334,198x58,0,0{99x58,0,0,118,98x58,100,0,273}] @46

tmux panes: 1: [198x57] [history 1886/2000, 757552 bytes] %11 (active)

tmux global options: @logging-filename "#{session_name}-#{window_name}-#{pane_index}.log" @logging-path /Users/edgeb1/log/tmux/%Y-%m-%d @pane_resize 5 @plugin christoomey/vim-tmux-navigator activity-action other assume-paste-time 1 base-index 0 bell-action any default-command "reattach-to-user-namespace -l /usr/local/bin/zsh" default-shell /usr/local/bin/zsh default-size 80x24 destroy-unattached off detach-on-destroy on display-panes-active-colour colour33 display-panes-colour colour166 display-panes-time 1000 display-time 4000 history-limit 2000 key-table root lock-after-time 0 lock-command "lock -np" message-command-style fg=yellow,bg=black message-style fg=colour166,bg=colour235 mouse on prefix ` prefix2 Invalid#1fff00000000 renumber-windows off repeat-time 500 set-titles off set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}" silence-action other status on status-bg default status-fg default status-format[0] "#[align=left range=left #{status-left-style}]#[push-default]#{T;=/#{status-left-length}:status-left}#[pop-default]#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#[push-default]#{T:window-status-format}#[pop-default]#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{window-status-current-style},default},#{window-status-current-style},#{window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#[push-default]#{T:window-status-current-format}#[pop-default]#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{status-right-style}]#[push-default]#{T;=/#{status-right-length}:status-right}#[pop-default]#[norange default]" status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }" status-interval 1 status-justify centre status-keys vi status-left "#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]" status-left-length 20 status-left-style default status-position bottom status-right "#[fg=green,bg=default,bright]#(tmux-mem-cpu-load) #[fg=red,dim,bg=default]#(uptime | cut -f 4-5 -d \" \" | cut -f 1 -d \",\") #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d" status-right-length 140 status-right-style default status-style bright update-environment[0] DISPLAY update-environment[1] KRB5CCNAME update-environment[2] SSH_ASKPASS update-environment[3] SSH_AUTH_SOCK update-environment[4] SSH_AGENT_PID update-environment[5] SSH_CONNECTION update-environment[6] WINDOWID update-environment[7] XAUTHORITY visual-activity off visual-bell off visual-silence off word-separators " "

tmux window options: aggressive-resize off allow-rename off alternate-screen on automatic-rename on automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}" clock-mode-colour colour64 clock-mode-style 24 main-pane-height 24 main-pane-width 80 mode-keys vi mode-style fg=black,bg=yellow monitor-activity off monitor-bell on monitor-silence 0 other-pane-height 0 other-pane-width 0 pane-active-border-style fg=green pane-base-index 1 pane-border-format "#{pane_index} #{pane_title}" pane-border-status bottom pane-border-style default remain-on-exit off synchronize-panes off window-active-style bg=colour234 window-size latest window-style fg=colour247,bg=colour235 window-status-activity-style reverse window-status-bell-style reverse window-status-current-format " #{window_index} #{window_name} " window-status-current-style fg=#000000,bg=yellow window-status-format "#{window_index} #{window_name}" window-status-last-style default window-status-separator " " window-status-style fg=brightblue wrap-search on xterm-keys on


  * Include any other pertinant system info not captured

[I] ➜ tmux -V tmux 3.1c

tony commented 1 year ago

It's been a long time since this was posted. Not sure if it's still the case or not - but I suppose so

Note that this does work if I specify a unique session name for each yml

So it worked then. If so, that makes sense with the current behavior.

Right now - tmuxp treats workspace files with the same session_name as already loaded. They need to be named differently. Perhaps we can change that assumption (I'm redoing the test infrastructure and loading code in other PRs)

bedge commented 1 year ago

@tony Appreciate the mental bandwidth of working through the post.

My argument for the change is be the ability to append to an existing session programmatically, vs needing to create a new session just to add a window, that really belonged on the existing session.

tony commented 1 year ago

@bedge Got it

A PR at #839 may graze upon this issue

For this specific case:

Some underlying code in cli/load.py may need to be changed.