vimux icon indicating copy to clipboard operation
vimux copied to clipboard

Tmux 3.1 deprecated the `-p` flag

Open jez opened this issue 1 year ago • 3 comments

Using the -p flag on split-window to say that the new splits size is a certain percentage has been deleted in 3.1, and will produce a Size missing error when you try to call split-window. The replacement is that the existing -l flag can either take an exact number of lines (or columns if making a vertical split) specified like -l 10 or a percentage, specified using a percent sign like -l 20%, which means the same as the old -p 20.

Relevant links:

  • tmux/tmux CHANGES

  • The manpage entry for split-window in man tmux:

    split-window [-bdfhIvPZ] [-c start-directory] [-e environment] [-l size]
            [-t target-pane] [shell-command] [-F format]
                  (alias: splitw)
            Create a new pane by splitting target-pane: -h does a horizontal
            split and -v a vertical split; if neither is specified, -v is as‐
            sumed.  The -l option specifies the size of the new pane in lines
            (for vertical split) or in columns (for horizontal split); size
            may be followed by ‘%’ to specify a percentage of the available
            space.  The -b option causes the new pane to be created to the
            left of or above target-pane.  The -f option creates a new pane
            spanning the full window height (with -h) or full window width
            (with -v), instead of splitting the active pane.  -Z zooms if the
            window is not zoomed, or keeps it zoomed if already zoomed.
    
            An empty shell-command ('') will create a pane with no command
            running in it.  Output can be sent to such a pane with the
            display-message command.  The -I flag (if shell-command is not
            specified or empty) will create an empty pane and forward any
            output from stdin to it.  For example:
    
                  $ make 2>&1|tmux splitw -dI &
    
            All other options have the same meaning as for the new-window
            command.
    

I only use tmux version 3.1 or later on my personal machines, so I have simply patched this plugin locally to always use -l ...% instead of -p ....

I leave it up to the maintainers of this project how to proceed with a proper fix. Either change the code to use -l 10% (which won't work on older versions of tmux, and thus might break existing Vimux users), or do some sort of version/feature detection to attempt to allow using Vimux with both old and new versions of tmux.

As always, thanks for the work on this project.

jez avatar Sep 24 '23 09:09 jez

Related: #217

mvanderkamp avatar Sep 29 '23 19:09 mvanderkamp

I think version detection would be appropriate, but that does open a can of worms since tmux is constantly changing features. The alternative is to say "sorry- try this tag of the plugin" to users with older versions of tmux. Perhaps version checking with a deprecation message?

mvanderkamp avatar Sep 29 '23 19:09 mvanderkamp

Another option would be a global option that stores the tmux command and/or flags used to open the split, which defaults to the flags required by the latest tmux version but can be overridden for users who want to use older versions.

In any case I defer to you! Again I’m already happy with my solution of editing the files directly in the mean time.

jez avatar Sep 30 '23 02:09 jez

The latest release of tmux appears to have completely dropped support for -p and this plugin is no longer functional as a result.

I can confirm the fix in #217 restores the plugin's functionality when using tmux 3.4.

ianchesal avatar Feb 19 '24 03:02 ianchesal

I wonder if that's deliberate, it looks like it's still supported, if I'm reading the code right: https://github.com/tmux/tmux/blob/608d113486835515e7a89b1511704440c68ae817/cmd-split-window.c#L97

That said, it looks like -l has been around for at least 15 years, at least since tmux has been tracked in git, possibly longer: https://github.com/tmux/tmux/blame/fc6a65c6207dbefcd8b5f187148978f8d4111b2b/cmd-split-window.c#L91

I vote we just use -l.

mvanderkamp avatar Feb 19 '24 04:02 mvanderkamp

Closed via #217.

alerque avatar Feb 19 '24 07:02 alerque