How to display a clock in tmux?

Quick Answer

To display a clock in tmux, press Ctrl+b t. This shows a full-screen digital clock in the current pane. Toggle between digital and analog styles with the A key while the clock is displayed. Exit clock mode by pressing Escape or q.

Ctrl+b t

Detailed Explanation

The clock feature in tmux is a simple utility that can display the current time in either digital or analog format. It takes over the current pane temporarily but doesn't interfere with your running processes.

Basic Clock Mode Usage

# Enter clock mode
Ctrl+b t

# Exit clock mode
q
# or
Escape

Using Clock Mode via Command

You can also enter clock mode using the tmux command interface:

# Enter digital clock mode
Ctrl+b :clock-mode

Customizing Clock Colors

You can customize the appearance of the clock by adding these settings to your ~/.tmux.conf file:

# Set the clock mode color
set-window-option -g clock-mode-colour green

# Set the 12-hour style
set-window-option -g clock-mode-style 12

The clock-mode-colour can be set to any color name or hex value that tmux supports.

Persistent Clock in Status Bar

Instead of using the temporary clock mode, you might prefer to have a permanent clock in your tmux status bar:

# Add time to the right side of status bar
set -g status-right '%H:%M %d-%b-%y'

# For a more detailed timestamp
set -g status-right '%Y-%m-%d %H:%M:%S'

# For time with timezone
set -g status-right '%H:%M %Z'

The format string follows the standard strftime format used in many programming languages.