45

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?

1
  • There is nothing like this built into tmux, but it came up on the mailing list recently. Nothing has been incorporated into the main source yet though. Aug 18, 2012 at 5:43

3 Answers 3

66

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'
5
  • 1
    What's the meaning of the "#22T"? In my computer it literally shows this code in the tmux's status bar and removing it seems harmless.
    – luizs81
    May 4, 2016 at 17:24
  • 2
    #T is the short version of #{pane_title}. The intervening number used to limit the length of the substituted value (so #22T would only show the first 22 characters of pane_title if it was too long). It was part of the (old) default value of status-right. The newer #{var_name} substitution syntax uses a different length-limiting syntax: #{=NN:var_name}. At some point support for the old length-limiting syntax must have been dropped. In modern tmux the default status-right uses #{=21:pane_title}. I’ll update the answer. May 4, 2016 at 19:17
  • 1
    Also, here is how you can inspect the default value of a setting: tmux -L none -f /dev/null start-server\; show-options -g status-right (where none is a currently unused tmux server socket name). May 4, 2016 at 19:22
  • 2
    I use the following for displaying it on the left side of the status bar (in case anyone else was wondering): set -g status-left '#{?client_prefix,#[reverse]<Prefix>#[noreverse] ,}[#S] '
    – rob
    Mar 14, 2018 at 22:10
  • This was really helpful.
    – Vinn
    Apr 18, 2022 at 1:46
6

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'
6

I created plugin for this. It indicates copy mode as well, is easily customizable and has good out-of-the-box experience.

https://github.com/dominikduda/tmux_mode_indicator

As readme says:

Plugin indicating normal/insert/prefix/copy modes.

It adds a new keyword, #{tmux_mode_indicator} to use in the string that defines your tmux status bar. Like this:

set -g status-right "#{tmux_mode_indicator}"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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