{"id":139657,"date":"2019-03-23T08:41:23","date_gmt":"2019-03-23T00:41:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=139657"},"modified":"2019-03-14T13:41:56","modified_gmt":"2019-03-14T05:41:56","slug":"windows-emacs-zsh","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/windows-emacs-zsh.html","title":{"rendered":"Windows \u4e0b Emacs \u4e2d\u7684 zsh shell \u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd0\u884c\u8de8\u5e73\u53f0 shell\uff08\u4f8b\u5982 Bash \u6216 zsh\uff09\u7684\u6700\u5927\u4f18\u52bf\u5728\u4e8e\u4f60\u80fd\u5728\u591a\u5e73\u53f0\u4e0a\u4f7f\u7528\u540c\u6837\u7684\u8bed\u6cd5\u548c\u811a\u672c\u3002\u5728 Windows \u4e0a\u8bbe\u7f6e\uff08\u66ff\u6362\uff09shell \u633a\u9ebb\u70e6\u7684\uff0c\u4f46\u6240\u83b7\u5f97\u7684\u56de\u62a5\u8fdc\u8fdc\u8d85\u51fa\u8fd9\u5c0f\u5c0f\u7684\u4ed8\u51fa\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"
\nMSYS2 \u5b50\u7cfb\u7edf\u5141\u8bb8\u4f60\u5728 Windows \u4e0a\u8fd0\u884c Bash \u6216 zsh \u4e4b\u7c7b\u7684 shell\u3002\u4f7f\u7528 MSYS2 \u5f88\u91cd\u8981\u7684\u4e00\u70b9\u5728\u4e8e\u786e\u4fdd\u641c\u7d22\u8def\u5f84\u90fd\u6307\u5411 MSYS2 \u5b50\u7cfb\u7edf\u672c\u8eab\uff1a\u5b58\u5728\u592a\u591a\u4f9d\u8d56\u5173\u7cfb\u4e86\u3002
\nMSYS2 \u5b89\u88c5\u540e\u9ed8\u8ba4\u7684 shell \u5c31\u662f Bash\uff1bzsh \u5219\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n

pacman -Sy zsh<\/pre>\n

\u901a\u8fc7\u4fee\u6539 etc\/passwd<\/span> \u6587\u4ef6\u53ef\u4ee5\u8bbe\u7f6e zsh \u4f5c\u4e3a\u9ed8\u8ba4 shell\uff0c\u4f8b\u5982\uff1a<\/p>\n

mkpasswd -c | sed -e 's\/bash\/zsh\/' | tee -a \/etc\/passwd<\/pre>\n

\u8fd9\u4f1a\u5c06\u9ed8\u8ba4 shell \u4ece bash \u6539\u6210 zsh\u3002<\/p>\n

\u8981\u5728 Windows \u4e0a\u7684 Emacs \u4e2d\u8fd0\u884c zsh \uff0c\u9700\u8981\u4fee\u6539 shell-file-name<\/span> \u53d8\u91cf\uff0c\u5c06\u5b83\u6307\u5411 MSYS2 \u5b50\u7cfb\u7edf\u4e2d\u7684 zsh \u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u8be5\u4e8c\u8fdb\u5236 shell \u6587\u4ef6\u5728 Emacs exec-path<\/span> \u53d8\u91cf\u4e2d\u7684\u67d0\u4e2a\u5730\u65b9\u3002<\/p>\n

(setq shell-file-name (executable-find \"zsh.exe\"))<\/pre>\n

\u4e0d\u8981\u5fd8\u4e86\u4fee\u6539 Emacs \u7684 PATH<\/span> \u73af\u5883\u53d8\u91cf\uff0c\u56e0\u4e3a MSYS2 \u8def\u5f84\u5e94\u8be5\u5148\u4e8e Windows \u8def\u5f84\u3002\u63a5\u4e0a\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5047\u8bbe MSYS2 \u5b89\u88c5\u5728c:\\programs\\msys2<\/span> \u4e2d\uff0c\u90a3\u4e48\u6267\u884c\uff1a<\/p>\n

(setenv \"PATH\" \"C:\\\\programs\\\\msys2\\\\mingw64\\\\bin;C:\\\\programs\\\\msys2\\\\usr\\\\local\\\\bin;C:\\\\programs\\\\msys2\\\\usr\\\\bin;C:\\\\Windows\\\\System32;C:\\\\Windows\")<\/pre>\n

\u5728 Emacs \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u597d\u8fd9\u4e24\u4e2a\u53d8\u91cf\u540e\uff0c\u5728 Emacs \u4e2d\u8fd0\u884c\uff1a<\/p>\n

M-x shell<\/pre>\n

\u5e94\u8be5\u5c31\u80fd\u770b\u5230\u719f\u6089\u7684 zsh \u63d0\u793a\u7b26\u4e86\u3002<\/p>\n

Emacs \u7684\u7ec8\u7aef\u8bbe\u7f6e\uff08eterm\uff09\u4e0e MSYS2 \u7684\u6807\u51c6\u7ec8\u7aef\u8bbe\u7f6e\uff08xterm-256color\uff09\u4e0d\u4e00\u6837\u3002\u8fd9\u610f\u5473\u7740\u67d0\u4e9b\u63d2\u4ef6\u548c\u4e3b\u9898\uff08\u63d0\u793a\u7b26\uff09\u53ef\u80fd\u4e0d\u80fd\u6b63\u5e38\u5de5\u4f5c - \u5c24\u5176\u5728\u4f7f\u7528 oh-my-zsh \u65f6\u3002<\/p>\n

\u68c0\u6d4b zsh \u5426\u5219\u5728 Emacs \u4e2d\u8fd0\u884c\u5f88\u7b80\u5355\uff0c\u4f7f\u7528\u53d8\u91cf $INSIDE_EMACS<\/span>\u3002<\/p>\n

\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\u7247\u6bb5\u53d6\u81ea .zshrc<\/span>\uff08\u5f53\u4ee5\u4ea4\u4e92\u5f0f shell \u6a21\u5f0f\u542f\u52a8\u65f6\u4f1a\u88ab\u52a0\u8f7d\uff09\uff0c\u5b83\u4f1a\u5728 zsh \u5728 Emacs \u4e2d\u8fd0\u884c\u65f6\u542f\u52a8 git \u63d2\u4ef6\u5e76\u66f4\u6539\u4e3b\u9898\uff1a<\/p>\n

# Disable some plugins while running in Emacs\r\nif [[ -n \"$INSIDE_EMACS\" ]]; then\r\n  plugins=(git)\r\n  ZSH_THEME=\"simple\"\r\nelse\r\n  ZSH_THEME=\"compact-grey\"\r\nfi<\/pre>\n

\u901a\u8fc7\u5728\u672c\u5730 ~\/.ssh\/config<\/span> \u6587\u4ef6\u4e2d\u5c06 INSIDE_EMACS <\/span>\u53d8\u91cf\u8bbe\u7f6e\u4e3a SendEnv<\/span> \u53d8\u91cf\u2026\u2026<\/p>\n

Host myhost\r\nSendEnv INSIDE_EMACS<\/pre>\n

\u2026\u2026\u540c\u65f6\u5728 ssh \u670d\u52a1\u5668\u7684 \/etc\/ssh\/sshd_config<\/span> \u4e2d\u8bbe\u7f6e\u4e3a AcceptEnv<\/span> \u53d8\u91cf\u2026\u2026<\/p>\n

AcceptEnv LANG LC_* INSIDE_EMACS<\/pre>\n

\u2026\u2026\u8fd9\u4f7f\u5f97\u5728 Emacs shell \u4f1a\u8bdd\u4e2d\u901a\u8fc7 ssh \u767b\u5f55\u53e6\u4e00\u4e2a\u8fd0\u884c\u7740 zsh \u7684 ssh \u670d\u52a1\u5668\u4e5f\u80fd\u5de5\u4f5c\u7684\u5f88\u597d\u3002\u5f53\u5728 Windows \u4e0b\u7684 Emacs \u4e2d\u7684 zsh \u4e0a\u901a\u8fc7 ssh \u8fdc\u7a0b\u767b\u5f55\u65f6\uff0c\u8bb0\u5f97\u4f7f\u7528\u53c2\u6570 -t<\/span>\uff0c-t<\/span> \u53c2\u6570\u4f1a\u5f3a\u5236\u5206\u914d\u4f2a\u7ec8\u7aef\uff08\u4e4b\u6240\u4ee5\u9700\u8981\u8fd9\u6837\uff0c\u65f6\u56e0\u4e3a Windows \u4e0b\u7684 Emacs \u5e76\u6ca1\u6709\u771f\u6b63\u7684 tty\uff09\u3002
\n\u8de8\u5e73\u53f0\uff0c\u5f00\u6e90\u771f\u662f\u4e2a\u597d\u4e1c\u897f\u2026\u2026<\/p>\n

via: https:\/\/www.onwebsecurity.com\/configuration\/zsh-shell-inside-emacs-on-windows.html<\/p>\n

\u4f5c\u8005\uff1aPeter Mosmans \u9009\u9898\uff1alujun9972 \u8bd1\u8005\uff1alujun9972 \u6821\u5bf9\uff1awxy<\/p>\n

\u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

MSYS2 \u5b50\u7cfb\u7edf\u5141\u8bb8\u4f60\u5728 Windows \u4e0a\u8fd0\u884c Bash \u6216 zsh \u4e4b\u7c7b\u7684 shell\u3002\u4f7f\u7528 MSYS2 […]<\/p>\n","protected":false},"author":63,"featured_media":139659,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-139657","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/139657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=139657"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/139657\/revisions"}],"predecessor-version":[{"id":139710,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/139657\/revisions\/139710"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/139659"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=139657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=139657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=139657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}