Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

give a hint when press prefix key in tmux

Tags:

tmux

When I press the prefix-key Ctrl-b tmux doesn't give me a hint that it has been pressed.

Sometimes I can not remember whether I have already pressed it or not.

Can I set up a hint like highlight/change color or show some special symbol in the status bar to show me when I have pressed the prefix-key?

like image 686
worldterminator Avatar asked Aug 17 '12 10:08

worldterminator


People also ask

How do I find the prefix key of tmux?

By default, tmux sets the prefix key as Ctrl + b.

What is prefix for tmux?

tmux may be controlled from an attached client by using a key combination of a prefix key, 'C-b' (Ctrl-b) by default, followed by a command key. The default command key bindings are: C-b Send the prefix key (C-b) through to the application. C-o Rotate the panes in the current window forwards.


2 Answers

The development version of tmux has support for this, so the next release (1.8?) should also support it.

There have been two changes that can be combined to indicate in your status line whether a prefix key has been pressed:

  • You can include the extended “format” replacements in the values of the “status” options. These replacements were first available in tmux 1.6, but they were not previously usable in the status options.
  • The client_prefix format replacement was added.

You could add a (conditional) highlighted <Prefix> string before the default status-right like this:

set -g status-right ' #{?client_prefix,#[reverse]<Prefix>#[noreverse] ,}"#{=21:pane_title}" %H:%M %d-%b-%y' 
like image 147
Chris Johnsen Avatar answered Sep 21 '22 05:09

Chris Johnsen


There's also a Tmux plugin called tmux-prefix-highlight that does this.
It adds a new keyword, #{prefix_highlight} to use in the string that defines your tmux status bar, like so:

set -g status-right '#{prefix_highlight} | %a %Y-%m-%d %H:%M' 
like image 29
arainone Avatar answered Sep 17 '22 05:09

arainone