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

Window Resize #18

Open
kenos1 opened this issue Jul 1, 2023 · 2 comments
Open

Window Resize #18

kenos1 opened this issue Jul 1, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@kenos1
Copy link

kenos1 commented Jul 1, 2023

Hi, I have been recently enjoying this plugin as it is a lot more simple than the tmux default keybindings. While it has been a pleasure to use this plugin, I have noticed that after refresh it snaps the vsplit and then split layout into a 50/50 ratio, though I prefer a ratio like 60/40. Though this repo hasn't had a commit in a long time, I won't mind having this request ignored if this project is abandoned.

@clementnuss
Copy link

I'm having the same issue. if someone happens to find a solution/alternative, would be happy to know

@jabirali
Copy link
Owner

Hi! Sorry for the delayed response; I've been busy switching jobs and moving cities recently :).

Internally, how this feature works is as follows:

  • tmux has pre-defined "layouts" which divides panes in the way you describe (e.g. "main-vertical" would be 50/50 vsplit, followed by even splits of the right half.) These are documented in man tmux (search for select-layout).
  • tmux has "hooks", which are similar to Vim autocommands. You define events (e.g. "opened new pane") that should trigger certain tmux commands to be executed. These are also documented in man tmux (search for set-hook).
  • tilish combines these two features to ensure that once a layout has been selected (e.g. "main-vertical"), then most window operations should preserve that layout. The relevant code can be found here:

    tmux-tilish/tilish.tmux

    Lines 229 to 244 in fef77c8

    # Define hooks {{{
    if [ -z "$legacy" ]
    then
    # Autorefresh layout after deleting a pane.
    tmux set-hook -g after-split-window "select-layout; select-layout -E"
    tmux set-hook -g pane-exited "select-layout; select-layout -E"
    # Autoselect layout after creating new window.
    if [ -n "${default:-}" ]
    then
    tmux set-hook -g window-linked "select-layout \"$default\"; select-layout -E"
    tmux select-layout "$default"
    tmux select-layout -E
    fi
    fi
    # }}}

Automatic re-application of layouts using hooks is supposed to be a feature of tilish, but I can certainly understand that it can get in the way if your preferred layout is not one of the tmux built-ins. Some proposed solutions:

  • If someone knows how to define custom layouts (e.g. your own version of "main-vertical" that does a 60/40 split instead), then I think this would be the best solution. I don't know how to do this. The man-page mentions an example like tmux select-layout bb62,159x48,0,0{79x48,0,0,79x48,80,0} that could perhaps be used as a starting point, but I don't know how to generalize it to work for any number of windows in a dynamic way (like how "main-vertical").
  • You can disable my hooks that autoresize windows. Either by deleting the lines linked above in your local copy of the plugin – or by attempting to remove the hooks at the bottom of your tmux.conf (I believe one or all of the commands set-hook -gu after-split-window, set-hook -gu pane-exited, set-hook -gu window-linked might do the trick.)
  • There is also an Open PR that I will try to test out as soon as I get time. I would love to hear your input on whether this helps resolve your issue as it sounds related.

Hope this helps, and glad to hear you're enjoying the plugin :)

@jabirali jabirali added the help wanted Extra attention is needed label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants