12

I have the following section in my tmux.conf file:

bind -r H resize-pane -L 10 # defaults to Ctrl-LeftArrow
bind -r J resize-pane -D 10
bind -r K resize-pane -U 10
bind -r L resize-pane -R 10

Id like to set a custom variable called step and assign it to 10 so I can reference it as:

bind -r H resize-pane -L $step

I don't know how to do that in tmux configuration file, but I think it should be possible.

1 Answer 1

10

Place this line in your config:

TMUX_STEP=10

And use it as such:

bind -r H resize-pane -L $TMUX_STEP
6
  • 2
    Does it have to start with TMUX_ prefix?
    – user86041
    Sep 15, 2017 at 20:31
  • 1
    @Chinggis6, no it does not.
    – Chris Hunt
    Nov 30, 2017 at 3:15
  • 1
    Does it have to be in ALL_CAPS?
    – krry
    Feb 23, 2019 at 21:37
  • 1
    No, it does not. Like standard bash variables. Mar 27, 2019 at 10:03
  • 2
    @Droj this is a strength of tmux: the bind-key command can run a simple shell command. Like all shell commands, this value (TMUX_STEP) can be taken from the environment variables when it is invoked. I'm not sure whether you can change this value (TMUX_STEP) in the current shell in tmux, or if it has to be from the session-creating shell, but the principle is the same.
    – Sam
    Nov 17, 2019 at 12:07

You must log in to answer this question.