starting tmux changes profile keys (character sequences sent)

115 views
Skip to first unread message

Ali Tofigh

unread,
Oct 30, 2012, 8:05:46 PM10/30/12
to iterm2-...@googlegroups.com
Hi,

I've used iterm2 for a while (I love it!) and I'm just trying out
tmux. I get the following strange behaviour from iterm:

I have only one profile defined in iterm2. I've set things up to work
with the gnu readline library and emacs (i.e., i've configured in my
iterm2 profile the character sequences that are sent by iterm2 and
recognized by readline and emacs). But when I start tmux on a remote
server, iterm2 suddenly changes the character sequences that are being
sent. They no longer correspond to my iterm2 profile.

For example, in my iterm2 profile Ctrl-left arrow sends the sequence
^[[1;5D. In my ~/.inputrc file I have the line '"\e[1;5D":
backward-word'. If I do ctrl-v followed by ctrl-left arrow, I get
exactly the output I expect, namely "^[[1;5D". BUT after starting
tmux, ctrl-left arrow no longer works (i.e., it does not result in
backward-word). ctrl-v ctrl-left arrow shows that the character
sequence being sent is "^[OD". How come?

/Ali

Scott Gifford

unread,
Oct 31, 2012, 12:21:36 AM10/31/12
to iterm2-...@googlegroups.com
On Tue, Oct 30, 2012 at 8:05 PM, Ali Tofigh <alix....@gmail.com> wrote:
[ ... ]
when I start tmux on a remote
server, iterm2 suddenly changes the character sequences that are being
sent. They no longer correspond to my iterm2 profile.

I'm more familiar with screen than tmux, but I think they both work the same way: screen/tmux will read the escape sequences from iterm2, then re-encode them before sending them on to the programs running inside.  So the keys are probably making it from iterm2 to tmux correctly, but then tmux is sending different keys to its terminals.  Your next step might be to take a close look at your tmux configuration.

Hope this helps,

-----Scott.

Ali Tofigh

unread,
Oct 31, 2012, 5:02:02 PM10/31/12
to iterm2-...@googlegroups.com
yes, you are right.

For others who might be in similar situation: I'm trying to get emacs
to work properly inside tmux. By putting this line in the tmux
configuration file

set-window-option -g xterm-keys on

tmux will generate xterm sequences. My next step is to figure out how
to get emacs to understand the xterm sequences even when TERM=screen.

/ali

Scott Gifford

unread,
Oct 31, 2012, 11:36:41 PM10/31/12
to iterm2-...@googlegroups.com
On Wed, Oct 31, 2012 at 5:02 PM, Ali Tofigh <alix....@gmail.com> wrote:
[ ... ] 
My next step is to figure out how

to get emacs to understand the xterm sequences even when TERM=screen.

Or just set TERM=xterm-color.

-----Scott.

Ali Tofigh

unread,
Nov 1, 2012, 2:55:12 AM11/1/12
to iterm2-...@googlegroups.com
It's just that tmux man page explicitly says that TERM must be set to screen or derivatives (like screen-256color) for programs running in a tmux session. 

/Ali
Reply all
Reply to author
Forward
0 new messages