I wanted to bind
⌘-} to switch windows in tmux (window is to tmux as tab is to everything else). Turns out tmux won’t let you bind to ⌘. I was able to solve this with a little hack in iTerm.
In iTerm preferences, click Profiles in the toolbar, then the Keys tab. You’ll see a lieelte
+ button there:
Click in the “Keyboard Shortcut” field, and mash the shortcut you want to use (in my case
Here is the real trick, choose “Send Hex Code” as the action.
Then in the field you want to enter the ascii code for what you want to send to tmux. In my case I used:
|Key Binding||Hex Code||Keys Sent||tmux command|
The other thing that makes this easier to keep tmux and iterm working nicely is to use the
prefix2 setting in tmux. That lets you keep
control-b working as a prefix binding, but you can also use a more comfortable binding when you are typing.
# Set C-f to prefix, but leave C-b in place set -g prefix2 C-f bind C-f send-prefix bind C-f last-window
I think this is a nice little trick that would work for more things than just tmux. Let me know if you find other clever uses for it.blog comments powered by Disqus