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

Second window comes into focus first #326

Closed
anmsh opened this issue Jan 6, 2018 · 22 comments · Fixed by #500
Closed

Second window comes into focus first #326

anmsh opened this issue Jan 6, 2018 · 22 comments · Fixed by #500

Comments

@anmsh
Copy link

anmsh commented Jan 6, 2018

I have a simple config with three windows. I have set focus: true for the first window to show upon loading a new session. Instead of the first, second window opens up.

session.yaml

session_name: daily
windows:
  - window_name: default
    focus: true
    layout: main-horizontal
    options:
      main-pane-height: 4
    panes:
    - shell_command:
      - watch acpi --thermal
    - shell_command:
      - task
  - window_name: projects
    start_directory: ~/projects
    panes:
    - shell_command:
      - ls
  - window_name: prog
    layout: main-horizontal
    panes:
    - shell_command:
      - py3
    - shell_command:
      - node

What is wrong with my configuration?

Version information:

tmuxp 1.3.5
tmux 2.6
Debian Testing

@laixintao
Copy link
Contributor

+1 same issue here.

It seems like tmuxp ignore focus and focus window6 randomly.

@Alrefai
Copy link

Alrefai commented Feb 12, 2018

I have the same issue, too.

@pjrulez
Copy link

pjrulez commented Mar 13, 2018

Try with "- " in front of focus: 'true'.
This is an example of the beginning of my .yaml file until the end of 1st window configuration:

session_name: OMG
start_directory: /home/pj
windows:
- focus: 'true'
  layout: 814f,190x48,0,0{95x48,0,0,0,94x48,96,0[94x24,96,0,1,94x23,96,25,2]}
  options:
    automatic-rename: 'off'
    monitor-activity: 'off'
    remain-on-exit: 'on'
  panes:
  - focus: 'true'
    shell_command:
    - l.
  - screenfetch
  - fortune | cowsay
  window_name: TERM

After this configuration for next window begind with - layout: and follows the same blueprint ending with window_name: X

Been just playing around, testing and it works fine on my side.

@laixintao
Copy link
Contributor

No, it didn't work:

Traceback (most recent call last):
  File "/Users/laixintao/.local/bin/tmuxp", line 11, in <module>
    sys.exit(cli.cli())
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/tmuxp/cli.py", line 602, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/tmuxp/cli.py", line 290, in load_workspace
    sconfig = config.trickle(sconfig)
  File "/Users/laixintao/.local/venvs/tmuxp/lib/python2.7/site-packages/tmuxp/config.py", line 360, in trickle
    for paneconfig in windowconfig['panes']:
KeyError: u'panes'

@Ilyes512
Copy link
Contributor

Focusing does not seem to work for me either. This is an example that I have (except for replacing the names):

session_name: work
windows:
  - window_name: Proxy
    start_directory: ~/Code/acme_docker/proxy
    panes:
      - docker-compose up
  - window_name: Satis
    start_directory: ~/Code/acme_docker/satis
    panes:
      - docker-compose up
  - window_name: Postal
    focus: true
    layout: even-horizontal
    start_directory: ~/Code/acme/postal-service
    panes:
      - docker-compose up
      - focus: true
  - window_name: FoobarService
    layout: even-horizontal
    start_directory: ~/Code/acme/foobar-service
    panes:
      - docker-compose up
      -
  - window_name: ProjectUnkown
    layout: even-horizontal
    start_directory: ~/Code/acme/unkown.project.nl
    panes:
      - docker-compose up
      -
  - window_name: ProjectZero
    layout: even-horizontal
    start_directory: ~/Code/acme/zero.project.nl
    panes:
      - docker-compose up
      -

When I execute the above it opens the window named ProjectUnkown instead of the one with the focus parameter. My tmux start counting from 1 instead of 0 so that might be the reason it did not open the last. (window 1 to window 6 instead of window 0 to window 5)

@anselmos
Copy link

anselmos commented Mar 24, 2018

/cc @tony PTAL - I might debug this and if I find what is wrong with it, try to fix it and create PR, but give me a hint if it's something that you already worked on or not ?

@tony
Copy link
Member

tony commented Mar 24, 2018

@anselmos Go ahead and give it a shot. This is an open issue

@rightaway
Copy link

Works for me when focus is set on the pane, but doesn't have any effect when set on the window.

@jgb
Copy link

jgb commented Oct 29, 2018

I confirm that even today with the newest version of tmuxp that focus works on panes, but has no effect on windows.

@ashdo
Copy link

ashdo commented Jan 29, 2019

i've fixed some typos and focus works for me
https://github.com/tmux-python/tmuxp/pull/473/files

@Blake-LeBlanc
Copy link

Thank you for looking into this @ashdo! It's still not working on my end when I follow the formatting example offered in the documentation (similar to @animeshb's example).

Is there anything further we can try to remedy the issue?

@qiaocco
Copy link

qiaocco commented May 27, 2019

not working too

@npearson72
Copy link

Been having this issue too. Using version 1.3.5

My hacky work-around is:

session_name: example
start_directory: ~/Dev/example
windows:
  - window_name: zsh
    panes:
      - sleep 1 && tmux select-window -t 1
  - window_name: rails
    layout: 6ca2,178x48,0,0{88x48,0,0,4,89x48,89,0[89x24,89,0,5,89x23,89,25,17]}
    panes:
      -
      - start_cp
      - bundle exec rails c
  - window_name: backround
    panes:
      - start_sidekiq

I add the tmux select-window to the window that tmuxp starts me in. Not sure if the start window will remain constant.

Would be nice to get this fixed properly.

@tony
Copy link
Member

tony commented Nov 6, 2019

Does #500 fix this issue properly for anyone? Looking for testers!

@tony tony closed this as completed in #500 Nov 6, 2019
@laixintao
Copy link
Contributor

It works for me, thanks!

@tony
Copy link
Member

tony commented Nov 7, 2019

@laixintao @animeshb @npearson72 @qiaocci @Blake-LeBlanc @ashdo @jgb @rightaway @Ilyes512 @anselmos @Alrefai @pjrulez Fix from #500 live in tmuxp 1.5.4

@qiaocco
Copy link

qiaocco commented Nov 8, 2019

It works, thanks a lot

@anmsh
Copy link
Author

anmsh commented Nov 8, 2019

Will try later this week and confirm. Thank you for putting your efforts into this fix.

@Blake-LeBlanc
Copy link

@laixintao @animeshb @npearson72 @qiaocci @Blake-LeBlanc @ashdo @jgb @rightaway @Ilyes512 @anselmos @Alrefai @pjrulez Fix from #500 live in tmuxp 1.5.4

Will try it out this weekend and let you know, thanks Tony!

@anselmos
Copy link

anselmos commented Nov 9, 2019

Yeap I confirm it works on 1.5.4 version 🎉 Thanks!

@Blake-LeBlanc
Copy link

1.5.4 version fixes the issue on my end as well. Thank you @tony !

@anmsh
Copy link
Author

anmsh commented Dec 2, 2019

This works 🎉🥇. I can go back to my workflow!
Thanks!

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

Successfully merging a pull request may close this issue.