{"id":114,"date":"2016-02-03T15:03:59","date_gmt":"2016-02-03T15:03:59","guid":{"rendered":"http:\/\/www.beer.org\/blog\/?p=114"},"modified":"2016-12-23T18:29:09","modified_gmt":"2016-12-23T18:29:09","slug":"iterm2-arrow-keys-not-working-in-cursor-application-mode","status":"publish","type":"post","link":"https:\/\/www.beer.org\/blog\/index.php\/2016\/02\/03\/iterm2-arrow-keys-not-working-in-cursor-application-mode\/","title":{"rendered":"iterm2 arrow keys not working in cursor application mode"},"content":{"rendered":"<p>(TL;DR at the bottom)<\/p>\n<p>This is one of those things that irritated me for ages. \u00a0I generally don&#8217;t use arrow\/home\/end keys for anything except when I run (rarely) certain applications like &#8216;make menuconfig&#8217; where I&#8217;m forced to navigate using arrow keys.<\/p>\n<p>For the longest time, the arrow keys didn&#8217;t work on iterm2 in certain applications. \u00a0After digging in, I discovered the problem.<\/p>\n<p>Ages ago, I started using OS-X, but terminal.app sucked so I installed iterm. \u00a0Then iterm2 came out and I upgraded. \u00a0Sometime thereafter I discovered the arrow keys didn&#8217;t work. \u00a0This morning, I decided enough was enough and I got to the bottom of it. \u00a0One of the answers on\u00a0<a href=\"http:\/\/superuser.com\/questions\/130155\/arrow-keys-dont-work-in-htop-on-os-x-in-terminal\">this question<\/a>\u00a0posted a handy little script to test whether the keys work in cursor application mode:<\/p>\n<p>&nbsp;<\/p>\n<pre><code>sh -c \"$(cat &lt;&lt;\\EOF\r\nnoecho_appmode() {\r\n  stty -echo\r\n  printf '\\033[?1h'\r\n}\r\nmodes=\"$(stty -g)\"\r\nrestore_echo_and_appmode() {\r\n  stty \"$modes\"\r\n  printf '\\033[?1l'\r\n}\r\nprintf '\\nType &lt;Up&gt; &lt;Down&gt; &lt;Right&gt; &lt;Left&gt; &lt;Control-D&gt; &lt;Control-D&gt;\\n'\r\nprintf '(no output until after the first &lt;Control-D&gt;, please type \"blindly\")\\n\\t'\r\nnoecho_appmode             ; trap 'restore_echo_and_appmode' 0\r\ncat -v\r\nrestore_echo_and_appmode   ; trap ''                         0\r\nprintf '\\nExpected:\\n\\t'\r\nprintf 'kcu%c1\\n' u d f b | \/usr\/bin\/tput -S | cat -v\r\nprintf '\\n\\n'\r\nEOF\r\n)\"\r\n\r\n<\/code><\/pre>\n<p>This told me that iterm2 wasn&#8217;t working correctly. But it obviously works for many other people.<\/p>\n<p>TL;DR:<\/p>\n<p>&nbsp;<\/p>\n<p>When I upgraded from iterm to iterm2, my settings survived and Preferences-&gt;Profiles-&gt;Keys (NOT Preferences-&gt;Keys) contained overrides for the arrow keys and home\/end. \u00a0Once I loaded a Preset for &#8220;xterm default&#8221;, exited iterm2 and restarted it, arrow keys worked fine.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>(TL;DR at the bottom) This is one of those things that irritated me for ages. \u00a0I generally don&#8217;t use arrow\/home\/end keys for anything except when I run (rarely) certain applications like &#8216;make menuconfig&#8217; where I&#8217;m forced to navigate using arrow keys. For the longest time, the arrow keys didn&#8217;t work on iterm2 in certain applications&#8230;. <a class=\"moretag\" href=\"https:\/\/www.beer.org\/blog\/index.php\/2016\/02\/03\/iterm2-arrow-keys-not-working-in-cursor-application-mode\/\">Continue reading &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,7],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-memotoself","category-tech-stuff"],"_links":{"self":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":2,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":116,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/114\/revisions\/116"}],"wp:attachment":[{"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beer.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}