11

Currently I'll often do prefix-cprefix-, to open a new window then rename it. I would like to make prefix-c automatically ask for a name for the new window.

Basically I want it to behave as if I'd entered prefix-:new-window -n.How do I map prefix-c to that command?

I've tried adding bind-key c 'new-window -n' to my ~/.tmux.conf but that doesn't work.

Brett Y
  • 7,171
  • 1
  • 28
  • 42

1 Answers1

15

You'll need a prompt to ask for the new window name:

bind-key c command-prompt -p "window name:" "new-window; rename-window '%%'"
jasonwryan
  • 4,416
  • 1
  • 28
  • 25
  • Perfect, that's exactly what I was looking for! – Brett Y Aug 25 '14 at 01:13
  • 1
    This didn't work for me. I do a `C-b c` and get prompted for the name, but then the name doesn't get used. I get some default name. – meh Sep 23 '17 at 14:36
  • 1
    Nevermind. I needed to [stop automatic window renaming](https://stackoverflow.com/questions/17289439/tmux-window-title-keeps-renaming). This solution works for me. – meh Sep 23 '17 at 18:01