{"id":141479,"date":"2019-04-06T08:00:23","date_gmt":"2019-04-06T00:00:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=141479"},"modified":"2019-03-28T09:51:33","modified_gmt":"2019-03-28T01:51:33","slug":"zsh-install-use","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/zsh-install-use.html","title":{"rendered":"Zsh\u548coh my zsh\u7684\u5b89\u88c5\u548c\u4f7f\u7528"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nZsh \u517c\u5bb9 Bash\uff0c\u636e\u4f20\u8bf4 99% \u7684 Bash \u64cd\u4f5c \u548c Zsh \u662f\u76f8\u540c\u7684\uff0c\u9ed8\u8ba4 CentOS \/ Ubuntu \/ Mac \u7cfb\u7edf\u7528\u7684\u662f Bash\uff0c\u5012\u4e5f\u4e0d\u662f\u8bf4 Bash \u4e0d\u597d\uff0c\u800c\u662f\u8bf4\u6211\u4eec\u6709\u66f4\u597d\u7684\u9009\u62e9\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Zsh \u5b89\u88c5<\/strong><\/div>\n

\u5148\u770b\u4e0b\u4f60\u7684 CentOS \u652f\u6301\u54ea\u4e9b shell\uff1acat \/etc\/shells\uff0c\u6b63\u5e38\u7ed3\u679c\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n

\/bin\/sh\r\n\/bin\/bash\r\n\/sbin\/nologin\r\n\/bin\/dash\r\n\/bin\/tcsh\r\n\/bin\/csh\r\n<\/pre>\n

CentOS \u5b89\u88c5\uff1a<\/p>\n

sudo yum install -y zsh<\/pre>\n

\u5728\u68c0\u67e5\u4e0b\u7cfb\u7edf\u7684 shell\uff1acat \/etc\/shells\uff0c\u4f60\u4f1a\u53d1\u73b0\u591a\u4e86\u4e00\u4e2a\uff1a\/bin\/zsh<\/p>\n

\u4f7f\u7528 Zsh \u6269\u5c55\u96c6\u5408\uff1aoh-my-zsh<\/strong><\/div>\n

oh-my-zsh \u5e2e\u6211\u4eec\u6574\u7406\u4e86\u4e00\u4e9b\u5e38\u7528\u7684 Zsh \u6269\u5c55\u529f\u80fd\u548c\u4e3b\u9898\uff1ahttps:\/\/github.com\/robbyrussell\/oh-my-zsh,\u6211\u4eec\u65e0\u9700\u81ea\u5df1\u53bb\u6363\u641e Zsh\uff0c\u76f4\u63a5\u7528 oh-my-zsh \u5c31\u8db3\u591f\u4e86\uff0c\u5982\u679c\u4f60\u60f3\u7ee7\u7eed\u6df1\u9020\u7684\u8bdd\u90a3\u518d\u53bb\u5f04\u3002
\n\u5b89\u88c5 oh-my-zsh\uff08\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u80fd\u4f1a\u6709\u70b9\u6162\uff0c\u6216\u8005\u9700\u8981\u91cd\u8bd5\u51e0\u6b21\uff09\uff1a<\/p>\n

wget sh -c \"$(curl -fsSL https:\/\/raw.github.com\/robbyrussell\/oh-my-zsh\/master\/tools\/install.sh)\"<\/pre>\n

\u6574\u4e2a\u8fc7\u7a0b\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n

\"\"\u5728\u4ee5 root \u7528\u6237\u4e3a\u524d\u63d0\u4e0b\uff0coh-my-zsh \u7684\u5b89\u88c5\u76ee\u5f55\uff1a\/root\/.oh-my-zsh
\n\u5728\u4ee5 root \u7528\u6237\u4e3a\u524d\u63d0\u4e0b\uff0cZsh \u7684\u914d\u7f6e\u6587\u4ef6\u4f4d\u7f6e\uff1a\/root\/.zshrc
\n\u4e3a root \u7528\u6237\u8bbe\u7f6e zsh \u4e3a\u7cfb\u7edf\u9ed8\u8ba4 shell\uff1achsh -s \/bin\/zsh root
\n\u5982\u679c\u4f60\u8981\u91cd\u65b0\u6062\u590d\u5230 bash\uff1achsh -s \/bin\/bash root
\n\u73b0\u5728\u4f60\u5173\u6389\u7ec8\u7aef\u6216\u662f\u91cd\u65b0\u8fde\u4e0a shell\uff0c\u73b0\u5728\u5f00\u5934\u662f\u4e00\u4e2a\u7bad\u5934\u4e86\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n

\"\"<\/p>\n

\u63d2\u4ef6\u63a8\u8350<\/strong><\/div>\n

\u542f\u7528 oh-my-zsh \u4e2d\u81ea\u5e26\u7684\u63d2\u4ef6\u3002oh-my-zsh \u7684\u63d2\u4ef6\u5217\u8868\u4ecb\u7ecd\uff08\u592a\u957f\u4e86\uff0c\u7528\u6e90\u7801\u4e0d\u7cbe\u51c6\u5730\u7edf\u8ba1\u4e0b\u6709 149 \u4e2a\uff09\uff1ahttps:\/\/github.com\/robbyrussell\/oh-my-zsh\/wiki\/Plugins \u3002\u6211\u4eec\u770b\u4e0b\u5b89\u88c5 oh-my-zsh \u7684\u65f6\u5019\u81ea\u5e26\u6709\u591a\u5c11\u4e2a\u63d2\u4ef6\uff1a<\/p>\n

ls -l \/root\/.oh-my-zsh\/plugins |grep \"^d\"|wc -l<\/pre>\n

\u6211\u8fd9\u8fb9\u5f97\u5230\u7684\u7ed3\u679c\u662f\uff1a211\u3002\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1avim \/root\/.zshrc\uff0c\u627e\u5230\u4e0b\u56fe\u7684\u5730\u65b9\uff0c\u600e\u4e48\u5b89\u88c5\uff0c\u539f\u4f5c\u8005\u6ce8\u91ca\u5199\u5f97\u5f88\u6e05\u695a\u4e86\uff0c\u522b\u88c5\u592a\u591a\u4e86\uff0c\u9ed8\u8ba4 git \u662f\u5b89\u88c5\u7684\u3002<\/p>\n

\"\"<\/p>\n

wd<\/strong><\/span><\/div>\n

\u7b80\u5355\u5730\u8bb2\u5c31\u662f\u7ed9\u6307\u5b9a\u76ee\u5f55\u6620\u5c04\u4e00\u4e2a\u5168\u5c40\u7684\u540d\u5b57\uff0c\u4ee5\u540e\u65b9\u4fbf\u76f4\u63a5\u8df3\u8f6c\u5230\u8fd9\u4e2a\u76ee\u5f55\uff0c\u6bd4\u5982\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0\u4e0a wd \u7684\u540d\u5b57\uff1avim \/root\/.zshrc
\n\u6211\u5e38\u53bb\u76ee\u5f55\uff1a\/opt\/setups\uff0c\u6bcf\u6b21\u8fdb\u5165\u8be5\u76ee\u5f55\u4e0b\u90fd\u9700\u8981\u8fd9\u6837\uff1acd \/opt\/setups
\n\u73b0\u5728\u7528 wd \u7ed9\u4ed6\u6620\u5c04\u4e00\u4e2a\u5feb\u6377\u65b9\u5f0f\uff1acd \/opt\/setups ; wd add setups
\n\u4ee5\u540e\u6211\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u53ea\u8981\u8fd0\u884c\uff1awd setups \u5c31\u81ea\u52a8\u8dd1\u5230 \/opt\/setups \u76ee\u5f55\u4e0b\u4e86
\n\u63d2\u4ef6\u5b98\u7f51\uff1ahttps:\/\/github.com\/mfaerevaag\/wd<\/p>\n

zsh-syntax-highlighting<\/strong><\/span><\/div>\n

\u8fd9\u4e2a\u63d2\u4ef6\u4f1a\u5bf9\u7ec8\u7aef\u547d\u4ee4\u9ad8\u4eae\u663e\u793a,\u6bd4\u5982\u6b63\u786e\u7684\u62fc\u5199\u4f1a\u662f\u7eff\u8272\u6807\u8bc6,\u5426\u5219\u662f\u7ea2\u8272,\u53e6\u5916\u5bf9\u4e8e\u4e00\u4e9bshell\u8f93\u51fa\u8bed\u53e5\u4e5f\u4f1a\u6709\u9ad8\u4eae\u663e\u793a,\u7b97\u662f\u4e0d\u9519\u7684\u8f85\u52a9\u63d2\u4ef6
\n\u63d2\u4ef6\u5b98\u7f51\uff1ahttps:\/\/github.com\/zsh-users\/zsh-syntax-highlighting
\n\u5b89\u88c5\uff0c\u590d\u5236\u8be5\u547d\u4ee4\uff1a'git clone https:\/\/github.com\/zsh-users\/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~\/.oh-my-zsh\/custom}\/plugins\/zsh-syntax-highlighting'
\n\u7f16\u8f91\uff1avim ~\/.zshrc\uff0c\u627e\u5230\u8fd9\u4e00\u884c\uff0c\u540e\u62ec\u53f7\u91cc\u9762\u7684\u540e\u9762\u6dfb\u52a0\uff1aplugins=( \u524d\u9762\u7684\u4e00\u4e9b\u63d2\u4ef6\u540d\u79f0 zsh-syntax-highlighting)
\n\u5237\u65b0\u4e0b\u914d\u7f6e\uff1asource ~\/.zshrc<\/p>\n

\u4e3b\u9898<\/strong><\/div>\n

\u5f88\u591a\u4eba\u559c\u6b22\u6363\u641e\u8fd9\u4e2a,\u6363\u641e\u4e3b\u9898\u548c\u63d2\u4ef6\u601d\u8def\u4e00\u6837
\noh-my-zsh \u7684\u4e3b\u9898\u5217\u8868\u4ecb\u7ecd\uff08\u8fd8\u662f\u592a\u957f\u4e86\uff09\uff1ahttps:\/\/github.com\/robbyrussell\/oh-my-zsh\/wiki\/Themes
\n\u6211\u4eec\u770b\u4e0b\u5b89\u88c5 oh-my-zsh \u7684\u65f6\u5019\uff0c\u81ea\u5e26\u6709\u591a\u5c11\u4e2a\uff1als -l \/root\/.oh-my-zsh\/themes |grep \"^-\"|wc -l\uff0c\u6211\u8fd9\u8fb9\u5f97\u5230\u7684\u7ed3\u679c\u662f\uff1a140\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1avim \/root\/.zshrc\uff0c\u627e\u5230\u4e0b\u56fe\u7684\u5730\u65b9\uff0c\u600e\u4e48\u5b89\u88c5\uff0c\u539f\u4f5c\u8005\u6ce8\u91ca\u5199\u5f97\u5f88\u6e05\u695a\u4e86\uff0c\u5982\u679c\u4f60\u6ca1\u7279\u522b\u7684\u559c\u6b22\u90a3\u5c31\u9009\u62e9\u968f\u673a\u5427\u3002<\/p>\n

\"\"\u914d\u7f6e\u597d\u65b0\u4e3b\u9898\u9700\u8981\u91cd\u65b0\u8fde\u63a5 shell \u624d\u80fd\u770b\u5230\u6548\u679c<\/p>\n

\u5176\u4ed6<\/strong><\/div>\n

\u547d\u4ee4\u522b\u540d\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 alias \u53ef\u4ee5\u67e5\u770b\u5df2\u7ecf\u6709\u7684\u547d\u4ee4\u522b\u540d
\n\u81ea\u5df1\u65b0\u589e\u4e00\u4e9b\u522b\u540d\uff0c\u7f16\u8f91\u6587\u4ef6\uff1avim ~\/.zshrc\uff0c\u5728\u6587\u4ef6\u52a0\u5165\u4e0b\u9762\u683c\u5f0f\u7684\u547d\u4ee4\uff0c\u6bd4\u5982\u4ee5\u4e0b\u662f\u7f51\u53cb\u63d0\u4f9b\u7684\u4e00\u4e9b\u601d\u8def\uff1a<\/p>\n

alias cls='clear'\r\nalias ll='ls -l'\r\nalias la='ls -a'\r\nalias grep=\"grep --color=auto\"\r\nalias -s html='vim' # \u5728\u547d\u4ee4\u884c\u76f4\u63a5\u8f93\u5165\u540e\u7f00\u4e3a html \u7684\u6587\u4ef6\u540d\uff0c\u4f1a\u5728 Vim \u4e2d\u6253\u5f00\r\nalias -s rb='vim' # \u5728\u547d\u4ee4\u884c\u76f4\u63a5\u8f93\u5165 ruby \u6587\u4ef6\uff0c\u4f1a\u5728 Vim \u4e2d\u6253\u5f00\r\nalias -s py='vim' # \u5728\u547d\u4ee4\u884c\u76f4\u63a5\u8f93\u5165 python \u6587\u4ef6\uff0c\u4f1a\u7528 vim \u4e2d\u6253\u5f00\uff0c\u4ee5\u4e0b\u7c7b\u4f3c\r\nalias -s js='vim'\r\nalias -s c='vim'\r\nalias -s java='vim'\r\nalias -s txt='vim'\r\nalias -s gz='tar -xzvf' # \u5728\u547d\u4ee4\u884c\u76f4\u63a5\u8f93\u5165\u540e\u7f00\u4e3a gz \u7684\u6587\u4ef6\u540d\uff0c\u4f1a\u81ea\u52a8\u89e3\u538b\u6253\u5f00\r\nalias -s tgz='tar -xzvf'\r\nalias -s zip='unzip'\r\nalias -s bz2='tar -xjvf'\r\n<\/pre>\n
\u5dee\u5f02<\/strong><\/div>\n

\u6211\u4eec\u73b0\u5728\u589e\u52a0\u7cfb\u7edf\u53d8\u91cf\u5728\uff1a\/etc\/profile \u540e\uff0c\u8f93\u5165\u547d\u4ee4\uff1asource \/etc\/profile \u4e4b\u540e\uff0c\u91cd\u542f\u670d\u52a1\u5668\u53d1\u73b0\u521a\u521a\u7684\u7cfb\u7edf\u53d8\u91cf\u73b0\u5728\u6ca1\u6548\u679c\u3002
\n\u89e3\u51b3\u529e\u6cd5\uff1avim ~\/.zshrc\uff0c\u5728\u8be5\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u589e\u52a0\u4e00\u884c\uff1asource \/etc\/profile\uff0c\u7136\u540e\u5237\u65b0 zsh \u7684\u914d\u7f6e\uff1asource ~\/.zshrc\u3002\u5dee\u5f02
\n\u66f4\u591a\u4f7f\u7528\u65b9\u6cd5\u5927\u5bb6\u81ea\u5df1\u518d\u73a9\u73a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5148\u770b\u4e0b\u4f60\u7684 CentOS \u652f\u6301\u54ea\u4e9b shell\uff1acat \/etc\/shells\uff0c\u6b63\u5e38\u7ed3\u679c\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a \/bi […]<\/p>\n","protected":false},"author":362,"featured_media":141498,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-141479","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\/141479","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\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=141479"}],"version-history":[{"count":20,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/141479\/revisions"}],"predecessor-version":[{"id":141682,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/141479\/revisions\/141682"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/141498"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=141479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=141479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=141479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}