{"id":285,"date":"2012-02-28T17:56:39","date_gmt":"2012-02-28T22:56:39","guid":{"rendered":"http:\/\/zhanxw.com\/blog\/?p=285"},"modified":"2016-12-09T00:31:54","modified_gmt":"2016-12-09T06:31:54","slug":"iterm2%e5%92%8cemacs%e7%9a%84meta-key","status":"publish","type":"post","link":"https:\/\/zhanxw.com\/blog\/2012\/02\/iterm2%e5%92%8cemacs%e7%9a%84meta-key\/","title":{"rendered":"iTerm2\u548cEmacs\u7684Meta Key"},"content":{"rendered":"<p>How to set up Meta appropriately for iTerm2<\/p>\n<p>\u5b66\u6821\u7684\u7535\u8111\u662fMac\uff0cMac\u4e0b\u6700\u597d\u7684terminal\u662fiTerm2\uff1b\u6211\u7528\u7684\u7f16\u8f91\u5668\u662fEmacs\uff0c\u4f46Terminal\u4e0b\u7684Emacs\u4e0d\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u6bd4\u5982M+\/\u662f\u6211\u8bbe\u7f6e\u7684hippie-expand\uff0c\u6211\u4e0d\u80fd\u7528Alt\/Command + \/\u6309\u51fa\u6765\uff0c\u4e00\u5b9a\u8981\u7528Esc+\/ \u3002<br \/>\n\u88ab\u56f0\u6270\u4e86\u597d\u4e45\u4e4b\u540e\uff0c\u6211\u7ec8\u4e8e\u4e0b\u5b9a\u51b3\u5fc3\u5f7b\u5e95\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<br \/>\nNOTE\uff1aAlt\/Command \u6307\u7684\u662f\u4e00\u4e2a\u6309\u952e\uff0c\u5728windows\u952e\u76d8\u4e0a\u662fAlt\uff0cMac\u952e\u76d8\u4e0a\u53eb\u505aCommand\uff0c\u4e0a\u9762\u6709\u4e00\u4e2a\u56db\u74e3\u7684\u5c0f\u82b1\uff08Apple Clove\uff09<\/p>\n<p>\u9996\u5148\u8981\u5f04\u6e05\u695a\u6d41\u7a0b\uff1a<br \/>\n1. \u6211\u6309\u7684\u952e\u80fd\u4e0d\u80fd\u4f20\u5165iTerm2\uff1f<br \/>\n2. iTerm2\u5982\u4f55\u628a\u6211\u7684\u51fb\u952e\u4f20\u5230\u8fdc\u5904\u7684Linux Terminal\uff1f<br \/>\n3. \u8fdc\u7aef\u7684Terminal\u91cc\u7684Emacs\u80fd\u4e0d\u80fd\u6b63\u786e\u89e3\u6790\u51fb\u952e\uff1f<\/p>\n<p>1. \u6211\u6309\u7684\u952e\u80fd\u4e0d\u80fd\u4f20\u5165iTerm2\uff1f <\/p>\n<p>\u5728Mac\u7cfb\u7edf\uff0c\u4e00\u4e9b\u7ec4\u5408\u952e\u8fd8\u771f\u4e0d\u4e00\u5b9a\u80fd\u4f20\u5230iTerm2\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1aAlt\/Command + \/ \uff0c\u8fd9\u4e2a\u662fiTerm2\u91ccFind Cursor\u7684Shortcuts\uff0c\u5c31\u662f\u6211\u4e00\u6309\u8fd9\u4e2a\u7ec4\u5408\u952e\uff0c\u5c31\u6267\u884cFind Cursor\u7684\u529f\u80fd\uff0ciTerm\u91cc\u7684shell\u662f\u6536\u4e0d\u5230\u6211\u7684\u6309\u952e\u7684\u3002<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1a\u8be6\u7ec6\u89c1\u8fd9\u4e2a\u90ae\u4ef6\u5217\u8868 http:\/\/groups.google.com\/group\/iterm2-discuss\/browse_thread\/thread\/e960f5098ff3c4a0<br \/>\n\u5c31\u662f\u589e\u52a0\u4e00\u4e2a\u7cfb\u7edf\u7ea7\u522b\u7684\u8bbe\u7f6e\uff0c\u628aFind Cursor\u7684\u7ec4\u5408\u952eOverwrite\u6389\u3002<\/p>\n<p>\u987a\u4fbf\u8bf4\uff0c\u6211\u987a\u4fbf\u53d1\u73b0\u4e00\u4e2a\u5de5\u5177<a href=\"https:\/\/github.com\/fikovnik\/ShiftIt\" title=\"ShiftIt\" target=\"_blank\">ShiftIt<\/a>\uff0c\u5c31\u662f\u7528\u7ec4\u5408\u952e\u5b89\u6392\u7a97\u53e3\uff0c\u6bd4\u5982\uff1a\u628a\u7a97\u53e3\u6700\u5927\u5316\uff0c\u653e\u5728\u5de6\u8fb91\/2\uff0c\u53f3\u8fb91\/2\u2026\u2026 \u975e\u5e38\u987a\u624b\u3002<\/p>\n<p>2. iTerm2\u5982\u4f55\u628a\u6211\u7684\u51fb\u952e\u4f20\u5230\u8fdc\u5904\u7684Linux Terminal\uff1f<\/p>\n<p>\u4e0b\u9762\u662f\u5047\u8bbe\u6211\u6309\u4e0b\u952e\u4e86\uff0ciTerm2\u4f1a\u628a\u6211\u7684\u51fb\u952e\u4f20\u5230Linux Terminal\u4e0a\u3002\u6ce8\u610f\u8fd9\u4e2a\u8fc7\u7a0b\u5e76\u4e0d\u7b80\u5355\uff0c\u56e0\u4e3a\u6211\u7684\u6309\u952e\u4f1a\u88abremap\uff0c\u4e5f\u4f1a\u88ab\u6539\u52a8\u3002<br \/>\n\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u6211\u6309\u4e0bAlt\/Command\uff0c\u5982\u679c\u6709remap\uff08\u6bd4\u5982\u5728iTerm2\u91cc\u8bbe\u7f6e\u4e86\uff0c\u6216\u8005\u7528Double Command\u7b49\u8bbe\u7f6e\u4e86Remap\uff09\uff0c\u5b9e\u9645\u6253\u51fa\u7684\u53ef\u80fd\u662fOption\uff08\u5c31\u662fWindows\u952e\u76d8\u4e0a\u7684Win\u952e\uff09\u3002<br \/>\n\u8fd8\u6709\u4e00\u79cd\u53ef\u80fd\u662f\u6211\u7684\u51fb\u952e\u662fAlt\/Command\uff0c\u4f46Linux Terminal\u4e0d\u8ba4\u8bc6Alt\/Command\uff0c\u53ea\u6709\u5f3a\u5236iTerm2\u628aAlt\/Command\u8f93\u51fa\u6210+Esc \u624d\u6210\u3002<\/p>\n<p>\u7b80\u5355\u6765\u8bf4\uff0c\u5728iTerm2 \u9488\u5bf9\u6bcf\u4e2aSession\u7684\u8bbe\u5b9a\u91cc\uff0c\u5728\u8bbe\u5b9akeys\u65f6\uff0c\u9009\u62e9Preset xterm\uff1b\u7136\u540e\u628a\u5de6\u53f3Option Key\u90fd\u9009\u6210+Esc\u3002<br \/>\n\u53e6\u5916\u5728Linux Terminal\u4e2d.inputrc\u6587\u4ef6\u4e2d\u52a0\u5165\uff1a<br \/>\n<code>set input-meta on<br \/>\nset output-meta on<br \/>\nset convert-meta off<\/code><\/p>\n<p>\u66f4\u591a\u8d44\u6599\uff0c\u53c2\u89c1<a href=\"http:\/\/offbytwo.com\/2012\/01\/15\/emacs-plus-paredit-under-terminal.html\" title=\"Emacs + paredit under terminal (Terminal.app, iTerm, iTerm2)\" target=\"_blank\">\u5728iTerm2\u91cc\u8bbe\u7f6eEmacs \u548c paredit<\/a>\u4ee5\u53ca <a href=\"http:\/\/code.google.com\/p\/iterm2\/wiki\/Keybindings\" title=\"iTerm2 Keybinding\" target=\"_blank\">iTerm2\u5b98\u65b9\u8bb2Keybinding\u7684wiki<\/a><\/p>\n<p>\u5176\u4e2d\u5b98\u65b9wiki\u6307\u51fa\u4e86\u4e00\u4e2a\u6280\u5de7\uff0cCtrl\uff0bV\uff0c\u7136\u540e\u51fb\u952e\uff0c\u53ef\u4ee5\u770b\u51fa\u5230\u5e95\u5feb\u6377\u952e\u5177\u4f53\u662f\u4ec0\u4e48\uff0c\u6bd4\u5982Ctrl\uff0bv\uff0c\u7136\u540e\u6309Esc\uff0c\u5c31\u4f1a\u51fa\u73b0\uff1a&#8221;^[&#8220;, \u8bf4\u660eEsc\u5bf9\u5e94 ^[<\/p>\n<p>3. \u8fdc\u7aef\u7684Terminal\u91cc\u7684bash\/Emacs\u80fd\u4e0d\u80fd\u6b63\u786e\u89e3\u6790\u51fb\u952e\uff1f<\/p>\n<p>Bash \u5e38\u7528\u7684\u4e00\u4e2a\u529f\u80fd\u662fbackward-kill-word\uff0c\u5c31\u662f\u8bf4\u7528\u5feb\u6377\u952e\u5411\u524d\u5220\u9664\u5355\u8bcd\uff0c\u4e00\u822c\u53ef\u4ee5\u7528Ctrl+W\uff0c\u8fd8\u6709\u4e00\u79cd\u5e38\u7528\u7684\u5feb\u6377\u952e\u662fAlt+Backspace\u3002\u6bd4\u5982\u5728iTerm2\u91cc\u53ef\u4ee5Remap Alt+Backspace\uff0c\u4f46\u662f\u600e\u4e48\u624d\u80fd\u8f93\u5165Alt+Backspace\u5462\uff1f\u76f4\u63a5\u8f93\u5165\u65f6\uff0cBackspace\u4f1a\u5220\u9664\u4e0a\u4e00\u4e2a\u5b57\u7b26\uff0c\u8fd9\u65f6\u5019\u901a\u8fc7\u67e5<a href=\"http:\/\/www.bbdsoft.com\/ascii.html\" title=\"ASCII Table\" target=\"_blank\">ASCII\u8868<\/a>\uff0c\u53ef\u4ee5\u770b\u5230Hex 0x17\u5bf9\u5e94backspace\uff0c\u90a3\u4e48\u6211\u5728iTerm2\u91cc\u8bbe\u7f6e0x17\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u73b0\u5728\u5728Terminal \u65b9\u5f0f\u7684Emacs\u91cc\u9762\uff08emacs -nw\u65b9\u5f0f\uff09\uff0c\u5e94\u8be5\u53ef\u4ee5\u7528Option\u6765\u4ee3\u66ffMeta\u952e\uff0c\u6bd4\u5982Meta+\/\u53ef\u4ee5\u7528Option+\/\u6765\u8f93\u5165\u3002\u4f46\u5982\u679c\u6211\u8fd8\u662f\u4e60\u60ef\u7528Alt\/Command+\/\u600e\u4e48\u529e\uff1f<br \/>\n\u4e3a\u4e86\u4e0d\u5728Emacs\u91cc\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u5728iTerm2\u4e2d\u8bbe\u7f6e Alt\/Command + \/ \u4e3a\u53d1\u9001Escaped sequenced: ^[ \/<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6309\u4e86\u5feb\u6377\u952e\uff0c\u53ea\u6709\u8981Emacs\u4e8b\u5148\u77e5\u9053\u5feb\u6377\u952e\u5bf9\u5e94\u4ec0\u4e48\u529f\u80fd\u624d\u884c\u3002\uff08\u4f8b\u5982\u53ef\u4ee5\u7528Ctrl+h k\u6765\u770b\u6211\u4eec\u8f93\u5165\u7684\u5feb\u6377\u952e\u5bf9\u5e94\u7684\u529f\u80fd\uff09\u3002<\/p>\n<p>\u7ecf\u8fc7\u4ee5\u4e0a\u4e09\u6b65\uff0c\u73b0\u5728\u5982\u679c\u6211\u9700\u8981\u5728Emacs\u91cc\u8f93\u5165Alt\/Command + \/\uff0c \u53ef\u4ee5\u6309Esc+\/ , Alt\/Command + \/, \u6216Option + \/ .<br \/>\n\u5f53\u7136\u597d\u5904\u4e0d\u6b62\u5982\u6b64\uff0c\u6bd4\u5982\u5728Emacs\u91cc\u5404\u4e2a\u7a97\u53e3\u79fb\u52a8\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u7528Shift+ArrowKey\uff1b \u5728\u4e00\u4e2a\u6587\u6863\u5feb\u901f\u79fb\u52a8\uff0c\u53ef\u4ee5\u7528Ctrl+ArrowKey\u3002\u5f53\u7136\u6700\u5927\u7684\u597d\u5904\u662f\u53ef\u4ee5\u7528Option\u4f5c\u4e3aMeta\uff0c\u4ee5\u540e\u6309\u952e\u5c31\u65b9\u4fbf\u591a\u4e86\u3002<\/p>\n<p>2016-12-09\u8865\u5145<br \/>\n\u5982\u679c\u5728GNU screen\u91cc\u7528Emacs\uff0c\u9700\u8981\u5728.screenrc\u91cc\u52a0\u5165\u8fd9\u4e24\u884c\uff1a<br \/>\n<code>term xterm<br \/>\nc1 off<\/code><br \/>\n\u8fd9\u662f\u4e3a\u4e86\u786e\u4fddGNU screen\u4e0d\u4f1a\u6539\u53d8\u952e\u76d8\u4e0a\u8f93\u5165\u7684Escape sequence\u3002<br \/>\n\u6362\u53e5\u8bdd\u8bf4\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u201cShift\uff0b\u5411\u53f3\u7684\u7bad\u5934\u201d\u53ef\u4ee5\u4ece\u952e\u76d8\u9001\u5230Emacs\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to set up Meta appropriately for iTerm2 \u5b66\u6821\u7684\u7535\u8111\u662fMac\uff0cMac\u4e0b\u6700\u597d\u7684terminal\u662fiTerm2\uff1b\u6211\u7528\u7684\u7f16\u8f91\u5668\u662fEmacs\uff0c\u4f46Terminal\u4e0b\u7684Emacs\u4e0d\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u6bd4\u5982M+\/\u662f\u6211\u8bbe\u7f6e\u7684hippie-expand\uff0c\u6211\u4e0d\u80fd\u7528Alt\/Command + \/\u6309\u51fa\u6765\uff0c\u4e00\u5b9a\u8981\u7528Esc+\/ \u3002 \u88ab\u56f0\u6270\u4e86\u597d\u4e45\u4e4b\u540e\uff0c\u6211\u7ec8\u4e8e\u4e0b\u5b9a\u51b3\u5fc3\u5f7b\u5e95\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002 NOTE\uff1aAlt\/Command \u6307\u7684\u662f\u4e00\u4e2a\u6309\u952e\uff0c\u5728windows\u952e\u76d8\u4e0a\u662fAlt\uff0cMac\u952e\u76d8\u4e0a\u53eb\u505aCommand\uff0c\u4e0a\u9762\u6709\u4e00\u4e2a\u56db\u74e3\u7684\u5c0f\u82b1\uff08Apple Clove\uff09 \u9996\u5148\u8981\u5f04\u6e05\u695a\u6d41\u7a0b\uff1a 1. \u6211\u6309\u7684\u952e\u80fd\u4e0d\u80fd\u4f20\u5165iTerm2\uff1f 2. iTerm2\u5982\u4f55\u628a\u6211\u7684\u51fb\u952e\u4f20\u5230\u8fdc\u5904\u7684Linux Terminal\uff1f 3. \u8fdc\u7aef\u7684Terminal\u91cc\u7684Emacs\u80fd\u4e0d\u80fd\u6b63\u786e\u89e3\u6790\u51fb\u952e\uff1f 1. \u6211\u6309\u7684\u952e\u80fd\u4e0d\u80fd\u4f20\u5165iTerm2\uff1f \u5728Mac\u7cfb\u7edf\uff0c\u4e00\u4e9b\u7ec4\u5408\u952e\u8fd8\u771f\u4e0d\u4e00\u5b9a\u80fd\u4f20\u5230iTerm2\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1aAlt\/Command + \/ \uff0c\u8fd9\u4e2a\u662fiTerm2\u91ccFind Cursor\u7684Shortcuts\uff0c\u5c31\u662f\u6211\u4e00\u6309\u8fd9\u4e2a\u7ec4\u5408\u952e\uff0c\u5c31\u6267\u884cFind Cursor\u7684\u529f\u80fd\uff0ciTerm\u91cc\u7684shell\u662f\u6536\u4e0d\u5230\u6211\u7684\u6309\u952e\u7684\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a\u8be6\u7ec6\u89c1\u8fd9\u4e2a\u90ae\u4ef6\u5217\u8868 http:\/\/groups.google.com\/group\/iterm2-discuss\/browse_thread\/thread\/e960f5098ff3c4a0 \u5c31\u662f\u589e\u52a0\u4e00\u4e2a\u7cfb\u7edf\u7ea7\u522b\u7684\u8bbe\u7f6e\uff0c\u628aFind Cursor\u7684\u7ec4\u5408\u952eOverwrite\u6389\u3002 \u987a\u4fbf\u8bf4\uff0c\u6211\u987a\u4fbf\u53d1\u73b0\u4e00\u4e2a\u5de5\u5177ShiftIt\uff0c\u5c31\u662f\u7528\u7ec4\u5408\u952e\u5b89\u6392\u7a97\u53e3\uff0c\u6bd4\u5982\uff1a\u628a\u7a97\u53e3\u6700\u5927\u5316\uff0c\u653e\u5728\u5de6\u8fb91\/2\uff0c\u53f3\u8fb91\/2\u2026\u2026 \u975e\u5e38\u987a\u624b\u3002 2. iTerm2\u5982\u4f55\u628a\u6211\u7684\u51fb\u952e\u4f20\u5230\u8fdc\u5904\u7684Linux Terminal\uff1f \u4e0b\u9762\u662f\u5047\u8bbe\u6211\u6309\u4e0b\u952e\u4e86\uff0ciTerm2\u4f1a\u628a\u6211\u7684\u51fb\u952e\u4f20\u5230Linux Terminal\u4e0a\u3002\u6ce8\u610f\u8fd9\u4e2a\u8fc7\u7a0b\u5e76\u4e0d\u7b80\u5355\uff0c\u56e0\u4e3a\u6211\u7684\u6309\u952e\u4f1a\u88abremap\uff0c\u4e5f\u4f1a\u88ab\u6539\u52a8\u3002 \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u6211\u6309\u4e0bAlt\/Command\uff0c\u5982\u679c\u6709remap\uff08\u6bd4\u5982\u5728iTerm2\u91cc\u8bbe\u7f6e\u4e86\uff0c\u6216\u8005\u7528Double Command\u7b49\u8bbe\u7f6e\u4e86Remap\uff09\uff0c\u5b9e\u9645\u6253\u51fa\u7684\u53ef\u80fd\u662fOption\uff08\u5c31\u662fWindows\u952e\u76d8\u4e0a\u7684Win\u952e\uff09\u3002 \u8fd8\u6709\u4e00\u79cd\u53ef\u80fd\u662f\u6211\u7684\u51fb\u952e\u662fAlt\/Command\uff0c\u4f46Linux Terminal\u4e0d\u8ba4\u8bc6Alt\/Command\uff0c\u53ea\u6709\u5f3a\u5236iTerm2\u628aAlt\/Command\u8f93\u51fa\u6210+Esc \u624d\u6210\u3002 \u7b80\u5355\u6765\u8bf4\uff0c\u5728iTerm2 \u9488\u5bf9\u6bcf\u4e2aSession\u7684\u8bbe\u5b9a\u91cc\uff0c\u5728\u8bbe\u5b9akeys\u65f6\uff0c\u9009\u62e9Preset xterm\uff1b\u7136\u540e\u628a\u5de6\u53f3Option Key\u90fd\u9009\u6210+Esc\u3002 \u53e6\u5916\u5728Linux Terminal\u4e2d.inputrc\u6587\u4ef6\u4e2d\u52a0\u5165\uff1a set [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[33,79,14,80,81,82],"class_list":["post-285","post","type-post","status-publish","format-standard","hentry","category-sysadmin","tag-emacs","tag-iterm2","tag-linux","tag-mac","tag-meta","tag-readline"],"_links":{"self":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":0,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}