Search code examples
terminaltmux

Tmux running rename keeps old window name - how to I clear it?


So I use the following to rename my tmux windows:

tmux rename-window (prefix + ,) rename the current window

But when I do that command it keeps the old window name and I have to clear it to put in the new window name. Is there a way to have it cleared when I do prefix + , so I can just start typing the new window name?


Solution

  • You can remove the default value by adding something like this to your .tmux.conf:

    unbind ,
    bind-key , command-prompt -p (rename-window) "rename-window '%%'"
    

    This will:

    • clear the current bind for the , key
    • re-bind the , key to the command-prompt function
    • specifies a prompt message via -p (rename-window)
    • ends with a command specifier, which uses the input value (%%) as a parameter to the rename-window function

    To emulate the existing behaviour, it would look like:

    bind-key , command-prompt -I #W -p (rename-window) "rename-window '%%'"
    

    ...which tells command-prompt to use the current window name (#W, an alias for #{window_name}) as the initial, default value of the command prompt.