libtmux icon indicating copy to clipboard operation
libtmux copied to clipboard

Strict detection of tmux version via regex

Open mdeguzis opened this issue 3 years ago • 4 comments

See: #396

This change uses a more precise regex method to grab the tmux version string, taking into account the many variations of tmux versions:

# tmux 3.3a · tmux 3.3 · tmux 3.2a · tmux 3.2 · tmux 3.1c · tmux 3.1b · tmux tmux.org 2.8

I tested my change locally with tmuxp as well:

[dev-dsk-deguzim-1a-fa82568b DeGuzim-Config]$ tmuxp freeze --force -f yaml --yes --quiet
Save to: /home/deguzim/.tmuxp/work.yaml [/home/deguzim/.tmuxp/work.yaml]: 
[dev-dsk-deguzim-1a-fa82568b DeGuzim-Config]$ cat ~/.tmuxp/work.yaml 
session_name: work
windows:
- focus: 'true'
  layout: 61a9,231x42,0,0[231x16,0,0{150x16,0,0,0,80x16,151,0,2},231x25,0,17,1]
  options: {}
  panes:
  - shell_command:
    - cd /local/home/deguzim/src/libtmux
    - zsh
  - shell_command:
    - cd /local/home/deguzim/src/tmuxp
    - zsh
  - focus: 'true'
    shell_command:
    - cd /local/home/deguzim/src/DeGuzim-Config
    - python3
  window_name: zsh

Testing with python3:

>>> ver = "tmux 1.8"
>>> import re
>>> re.search('[0-9]{1}.[0-9]', ver).group(0)
'2.8'

>>> ver = "tmux 2.3"
>>> re.search('[0-9]{1}.[0-9]', ver).group(0)
'2.3'

Regex 101 test: https://regex101.com/r/y7jsSJ/1

mdeguzis avatar Aug 11 '22 14:08 mdeguzis

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 11 '22 14:08 CLAassistant

@mdeguzis I will give your PR priority review if you have more commits

I can also take a stab at it (but would be happy if yours got in so you get credit!)

tony avatar Aug 21 '22 17:08 tony

I should be able to look at the comments this week and see what I can do.

mdeguzis avatar Aug 24 '22 01:08 mdeguzis

@mdeguzis That sounds fine!

tony avatar Aug 24 '22 01:08 tony

@mdeguzis Is this a PR you're still interested in?

tony avatar Dec 10 '22 20:12 tony