You want to invoke a sequence of keystrokes (first Ctrl-b
, then n ranging from 0 to 9).
Your best bet is to use a keyboard shortcut utility such as Butler or Keyboard Maestro to do this for you.
Using Butler:
Select + » Smart Item » Keystrokes, configure the hotkey Cmd-1
. Press Ctrl-B
, then 1
for the Keystrokes. Configure it to be only valid in Terminal (or iTerm). It will warn you that other applications might not like it, but you know that already.
Using Keyboard Maestro:
Create a new group on the left that is only available in Terminal (or iTerm).
Add a new item, triggered by Hot Key Trigger (Cmd-1
) and add two Keystrokes to its actions: Ctrl-B
and 1
.
You might also want to take a look at this topic -- doesn't use Command
though, and didn't work for me using Terminal.
From the tmux documentation:
Bind key key to command. Keys may be specified prefixed with ‘C-’ or ‘ˆ’ for ctrl keys, or ‘M-’ for alt (meta) keys. The −r flag indicates this key may repeat, see the repeat-time option.
They don't support a third modifier key.
So, when you ssh into the server, you can use reverse tunneling so that you can talk back to your OSX machine to send it commands do pbcopy
.
ssh -R 1234:localhost:22 remoteServer
Replace 1234
with any open port the remote server. Then on the remote server, you can then run:
tmux save-buffer - | ssh -p 1234 localhost pbcopy
That should connect back to OSX and send the contents of your tmux copy buffer to it. You may want to use ssh keys to prevent typing your password to your OSX machine.
If that works for, you can then create your tmux keybindings.
bind C-c run "tmux save-buffer - | ssh -p 1234 localhost pbcopy"
I should note, for this to work, you will need to turn on Remote Sharing in OSX.
Secondary Option:
Since you're using OSX, if you're also using iTerm2, you might consider installing http://code.google.com/p/iterm2/downloads/detail?name=tmux-for-iTerm2-20120203.tar.gz&can=2&q= on your servers.
It's basically a custom tmux what supports the "-C" flag. This flag hands over windows, and panes and all their splitting to iTerm2.
Best Answer
I added this capability by...
set-option -g set-titles on
tmux new-session -s session_name
I have not yet figured out how to set the title from within the session, but it should be possible. Hope that helps!
Source URLs:
Rename Iterm2 tab from within tmux
https://gist.github.com/henrik/1967800