Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display current value of option in tmux display-message

I am binding a key in my tmux configuration for synchronize-panes window option. I would also like to display the current state of the same option with the same key press. So far, I have tried:

# one or more of the following
bind-key S run-shell "tmux setw synchronize-panes; TMUX_STATUS=`tmux showw synchronize-panes`;tmux display-message $TMUX_STATUS"
bind-key S "setw synchronize-panes; display-message `showw synchronize-panes`"
bind-key S run-shell "tmux setw synchronize-panes; TMUX_STATUS=$(tmux showw synchronize-panes); tmux display-message $TMUX_STATUS"
like image 353
hjpotter92 Avatar asked Apr 16 '17 16:04

hjpotter92


1 Answers

You can achieve that with the following binding in .tmux.conf

Tested with tmux 2.4

# Toggle synchronize-panes with ^S m
bind S \
    set synchronize-panes \;\
    display "Sync #{?synchronize-panes,ON,OFF}"

You have details about tmux variables and format in the man page. https://www.systutorials.com/docs/linux/man/1-tmux/

like image 123
Cléo Nordim Avatar answered Sep 22 '22 03:09

Cléo Nordim