前端之家收集整理的这篇文章主要介绍了
在Ubuntu上安装zsh,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
文以Ubuntu 12.04 LTS为例,安装目前比较流行的zsh的配置oh-my-zsh。oh-my-zsh最初是在OS X上供人使用,使用方法见此处。在Ubuntu上安装oh-my-zsh稍有不同。
安装
先安装zsh和Git,同时移除之前可能的oh-my-zsh的安装。
1
2
3
4
|
sudo
@H_ 403_28@apt-get
install
@H_ 403_28@zsh git
if
@H_ 403_28@[ -d ~/.oh-my-zsh ];
then
rm
@H_ 403_28@-r ~/.oh-my-zsh
fi
|
手动安装zsh是用于Ubuntu的sh
比较诡异,不识别source
这个指令。装好zsh后仿OS X
1
@H_ 403_28@wget https:
@H_ 403_28@//github
@H_ 403_28@.com
@H_ 403_28@/robbyrussell/oh-my-zsh/raw/master/tools/install
@H_ 403_28@.sh -O - | zsh
|
然后把shell切换成zsh,并重启计算机。
2
chsh -s `
which
@H_403_28@zsh`
sudo
shutdown
@H_ 403_28@-r 0
|
关于这个诡异问题的详细讨论见github上此issue
配置
oh-my-zsh有大量精美主题托管在项目中,可以在此预览 https://github.com/robbyrussell/oh-my-zsh/wiki/themes,我看中了其中最拉风的一款agnoster。把配置过程记录如下。
- 为了能够显示诸如分支(branch)、闪电(这个符号应该指拿到root权限)、错误(红色叉叉)、后台(一个齿轮)的各种符号,必须使用一个patch过的字体,在ubuntu下默认是Ubuntu Mono,OS X下坐着配的是Menlo,很多常见的等宽字体都打好了patch,当然也可以自己手动打patch。
1
|
cd
@H_ 403_28@~/.fonts/ && git clone https:
@H_ 403_28@//github
@H_ 403_28@.com
@H_ 403_28@/scotu/ubuntu-mono-powerline
@H_ 403_28@.git &&
~
|
- 在
~/.zshrc
把主题设置为agnoster
- 在
~/.zshrc
设定DEFAULT_USER
变量可以使得即使登陆在本机(即非SSH到远程)时也能显示“user@hostname”
这是我做的效果,Solarized Dark colorscheme这个配色没有适用于Ubuntu Terminal的。
以下是我的.zshrc
,只开了git一个plugin,还有很多plugin在~/.oh-my-zsh/plugin/
目录下,原来的sublime的plugin有点bug,我就放在我的.zshrc
的配置文件里面了。
https://gist.github.com/4015090.js?file=.zshrc
- #Pathtoyouroh-my-zshconfiguration.
- ZSH=$HOME/.oh-my-zsh
-
- #Setnameofthethemetoload.
- #Lookin~/.oh-my-zsh/themes/
- #Optionally,ifyousetthisto"random",it'llloadarandomthemeeach
- #timethatoh-my-zshisloaded.
- #ZSH_THEME="robbyrussell"
- ZSH_THEME="agnoster"
-
- #Examplealiases
- #aliaszshconfig="mate~/.zshrc"
- #aliasohmyzsh="mate~/.oh-my-zsh"
- #Settothistousecase-sensitivecompletion
- #CASE_SENSITIVE="true"
- #Commentthisouttodisableweeklyauto-updatechecks
- #DISABLE_AUTO_UPDATE="true"
- #Uncommentfollowinglineifyouwanttodisablecolorsinls
- #DISABLE_LS_COLORS="true"
- #Uncommentfollowinglineifyouwanttodisableautosettingterminaltitle.
- #DISABLE_AUTO_TITLE="true"
- #Uncommentfollowinglineifyouwantreddotstobedisplayedwhilewaitingforcompletion
- #COMPLETION_WAITING_DOTS="true"
- #Whichpluginswouldyouliketoload?(pluginscanbefoundin~/.oh-my-zsh/plugins/*)
- #Custompluginsmaybeaddedto~/.oh-my-zsh/custom/plugins/
- #Exampleformat:plugins=(railsgittextmaterubylighthouse)
- plugins=(git)
- aliasst='/usr/bin/sublime-text'
- source$ZSH/oh-my-zsh.sh
- #Customizetoyourneeds...
- exportPATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
- #optionallysetDEFAULT_USERin~/.zshrctoyourregularusernametohidethe“user@hostname”infowhenyou’reloggedinasyourselfonyourlocalmachine.
- DEFAULT_USER=tangkai@virtual-machine
转自:http://logicmd.net/2012/11/installing-zsh-on-ubuntu/