Yesterday, one of my friends asked me how to paste something into tmux command prompt. He’d like to change the working directory of currect session by entering,

attach -c <new working directory>

in command mode. And sometimes the new path was just too long so it’d be easier if he could simply copy and paste it, especially considering that there’s no path auto-completion in tmux command prompt.

Instinctively we’d use <prefix> + [ to enter into copy mode and copy something, pasting it anywhere by <prefix> + ]. However, we cannot send <prefix> in command mode. So we were looking for other solutions like copying something into system clipboards with integrated xclip or xsel and then pasting it by typing Ctrl + V, Cmd + V, etc. But unfortunately we don’t have these two packages installed on our workstation. At the end, I still had to spend some time looking into tmux manual for the built-in solution. And fortunately I found it!

command-prompt [-1i] [-I inputs] [-p prompts] [-t target-client] [template]
        Open the command prompt in a client.  This may be used from inside tmux to execute
        commands interactively.
        
        ...
        
        The following keys have a special meaning in the command prompt, depending on the
        value of the status-keys option:
        
                Function                             vi        emacs
                Cancel command prompt                Escape    Escape
                Delete current word                            C-w
                Delete entire command                d         C-u
                Delete from cursor to end            D         C-k
                Execute command                      Enter     Enter
                Get next command from history                  Down
                Get previous command from history              Up
                Insert top paste buffer              p         C-y
                
                ...

By default, it seems that the status-key option is set to emacs. So we only need to type Ctrl + y to insert from paste buffer in tmux command prompt.