{"id":17,"date":"2014-01-19T16:49:00","date_gmt":"2014-01-19T16:49:00","guid":{"rendered":""},"modified":"2016-02-25T18:09:02","modified_gmt":"2016-02-25T18:09:02","slug":"how-to-resize-tmux-windows-using-os-x-terminal","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=17","title":{"rendered":"How to resize tmux windows using OS X terminal"},"content":{"rendered":"<p>A while back I pointed out a blog post by someone else, which described how to get C-left and C-right working in tmux and OS X. Now I noticed that I cannot resize windows in tmux. This is because tmux seems to expect xterm keys for C-arrow. The xterm keycodes for the arrow keys are:<\/p>\n<ul>\n<li>left key: <span style=\"font-family: Courier New, Courier, monospace;\">^[[D<\/span><\/li>\n<li>right key: <span style=\"font-family: Courier New, Courier, monospace;\">^[[C<\/span><\/li>\n<li>up key: <span style=\"font-family: Courier New, Courier, monospace;\">^[[A<\/span><\/li>\n<li>down key: <span style=\"font-family: Courier New, Courier, monospace;\">^[[B<\/span><\/li>\n<li>C-left: <span style=\"font-family: Courier New, Courier, monospace;\">^[[1;5D<\/span><\/li>\n<li>C-right: <span style=\"font-family: Courier New, Courier, monospace;\">^[[1;5C<\/span><\/li>\n<li>C-up: <span style=\"font-family: Courier New, Courier, monospace;\">^[[1;5A<\/span><\/li>\n<li>C-down: <span style=\"font-family: Courier New, Courier, monospace;\">^[[1;5B<\/span><\/li>\n<\/ul>\n<p>I can now configure OS X terminal to send those key codes, and tmux works fine. However, other apps running in tmux will break, because they don&#8217;t expect to get xterm key codes. I found a workaround in the <a href=\"https:\/\/wiki.archlinux.org\/index.php\/tmux#Setting_the_correct_term\">ArchWiki<\/a>, which suggests to create your own terminfo entry. I will try that and report back here.<\/p>\n<div>Update: The solution is adding two lines to the ~\/.tmux.conf file:<\/p>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\"><span style=\"color: #afad24;\">set<\/span> -g default-terminal <span style=\"color: #34bd26;\">&#8220;xterm-256color&#8221;<\/span><\/span><\/div>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\"><span style=\"color: #afad24;\">setw<\/span> -g xterm-keys on &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/span><\/div>\n<\/div>\n<div>Update 2: And here is my OS X Terminal.app configuration:<\/p>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"\" style=\"margin-left: 1em; margin-right: 1em;\"><img loading=\"lazy\" border=\"0\" src=\"\" height=\"552\" width=\"640\" \/><\/a><\/div>\n<p>Update 3: And a very last update&#8230; It seems that tmux does not support bce (<a href=\"http:\/\/www.gnu.org\/software\/screen\/manual\/html_node\/Character-Processing.html\">background color erase<\/a>), which xterm does. This is a problem for progams like htop, vim, or mc. You will see rendering errors, if you do not fix this.<\/p>\n<p>So you need to make your own terminfo file and own terminal type, called xterm-256color-nobce. You can do this on the command line:<\/p>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\"><span style=\"color: #34bd26;\">pi@raspberrypi<\/span> <span style=\"color: #5330e1;\">~ $<\/span> infocmp xterm-256color | sed &#8216;s\/bce, \/\/&#8217; | sed &#8216;s\/xterm-256color\/xterm-256color-bce\/g&#8217; &gt; xterm-256color-nobce<\/span><\/div>\n<p>This will create a new terminfo source file, which does not advertise the bce feature. You can install this with the following command:<\/p>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\"><span style=\"color: #34bd26;\">pi@raspberrypi<\/span> <span style=\"color: #5330e1;\">~ $<\/span> sudo tic .\/xterm-256color-nobce<\/span><\/div>\n<p>This makes the terminal type xterm-256color-nobce available. After this, change your ~\/.tmux.conf once again, to use the new terminal type per default:<\/p>\n<div style=\"background-color: black; color: #af3782; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\"><span style=\"color: #ce7924;\">set<\/span> <span style=\"color: whitesmoke;\">-g default-terminal <\/span>&#8220;xterm-256color-nobce&#8221;<\/span><\/div>\n<\/div>\n<p>Update 4: To make the Ctrl+Arrow keys also work in regular OS X Terminal, you need to edit or create ~\/.inputrc to contain this:<\/p>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\"># xterm keys for skipping a word<\/span><\/div>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\">&#8220;e[1;5C&#8221;: forward-word<\/span><\/div>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\">&#8220;e[1;5D&#8221;: backward-word<\/span><\/div>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\">&#8220;e[5C&#8221;: forward-word<\/span><\/div>\n<div style=\"background-color: black; color: whitesmoke; font-size: 14px;\"><span style=\"font-family: Courier New, Courier, monospace;\">&#8220;e[5D&#8221;: backward-word<\/span><\/div>\n<div><\/div>\n<p>The &#8220;1;&#8221; variant is otherwise not recognized by GNU readline on OS X.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back I pointed out a blog post by someone else, which described how to get C-left and C-right working in tmux and OS X. Now I noticed that I cannot resize windows in tmux. This is because tmux seems to expect xterm keys for C-arrow. The xterm keycodes for the arrow keys are: &hellip; <a href=\"https:\/\/www.root42.de\/blog\/?p=17\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to resize tmux windows using OS X terminal&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,17,10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":1,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}