Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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: -------
# IF PANE_MAXIMIZED=False: 
# THEN: PANE_MAXIMIZED=True, and:
bind -n M-F new-window -d -n tmux-zoom  \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom

# Unmaximize pane -------
# IF PANE_MAXIMIZED=True: 
# THEN: PANE_MAXIMIZED=False, and:
bind -n M-F last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom
share|improve this question
1  
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

1 Answer 1

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

 
discard

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.