One-off tmux commands are easy to aim at the wrong session when they are typed from another shell. The interactive command prompt runs commands from the attached client, so the current session, window, and pane are already the default target unless the command names a different one.

The default key sequence is Ctrl-b then :. Ctrl-b is the prefix key, and : opens the command-prompt binding in the status-line area where tmux accepts the command name and arguments without the leading tmux shell command.

Prompt commands use the same parser as ~/.tmux.conf and other tmux command strings. Use one read-only command first in shared or long-running sessions, because command sequences separated with semicolons run immediately and state-changing commands such as rename-window, source-file, and kill-pane affect the live server.

Steps to use the tmux command prompt:

  1. Attach to the tmux session that should receive the prompt command.
    $ tmux attach -t work

    Replace work with the target session name. Skip this step when the correct tmux client is already attached.

  2. Confirm the default colon binding from a shell when the prompt key does not open.
    $ tmux list-keys -T prefix :
    bind-key -T prefix : command-prompt

    The output means the prefix table maps : to command-prompt. If the prefix key changed, press the configured prefix before :.

  3. Open the prompt inside the attached client.
    C-b :

    With the default prefix, press Ctrl-b, release it, then press :. The prompt appears in the status-line area; press Escape to cancel an empty prompt without running a command.

  4. Run a read-only command from the prompt.
    : display-message -p '#{session_name}'
    work

    display-message -p expands the tmux format and prints the selected session name. Press Enter to run the command; Tab can complete command names and arguments in the prompt.

  5. Open the prompt again before entering a separate command.
    C-b :

    The prompt closes after each command runs. Use C-b ~ to show recent tmux messages again when status-line output disappears too quickly.

  6. Rename the current window from the prompt.
    : rename-window admin

    rename-window changes the tmux title for the active window only.

  7. Verify the new window name from the prompt.
    : display-message -p '#{window_name}'
    admin

    The printed name confirms that tmux accepted the command typed at the prompt and applied it to the active window.