Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there is a way of defining a state variable in ./tmux.conf, such that depending on this variable, the keyboard binding would invoke a different command.

For example, I would like to use M-F to toggle the maximization of a pane in tmux (if the pane is not maximized, M-F would maximize it, otherwise it will unmaximize it)

Here is the pseudo-code that I have so far:

# Maximize pane: -------
bind -n M-F new-window -d -n tmux-zoom  \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom

# Unmaximize pane -------
bind -n M-F last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom
share|improve this question
Not a big tmux user but I doubt it, as implementing a near Turing complete interpreter is a big task. You could do this using an environment variable and shell scripts (calling tmux commands) though, since the shell is such an interpreter. – goldilocks Mar 6 '13 at 16:36

You can use the run-shell command to execute arbitrary shell commands, so this is certainly possible. This answer has a great example of this.

If all you're looking for is to toggle maximizing a window, as of version 1.8 that's a native tmux feature by use of the -Z flag to resize-pane (see this answer on superuser).

It's bound to tmux-prefix-z by default on my installation (via Homebrew on OS X).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.