在Linux下的终端各种方便,切换到mac下很不习惯。然后发现用iterm2+Oh-My-zsh竟然更加好用。
一,首先下面是安装过程
1,安装iterm2,安装过程忘记了。在网上找教程即可。
2,查看zsh
mac是自带zsh的,可以用命令查看:➜ /Users/zhangzhi >cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
一共6种
3,安装oh-my-zsh
(1)安装
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
(2)
设置默认的shell为Oh-My-ZSH,$ Mac环境下默认的shell为Bash$chsh -s /bin/zsh
不过在会报错如下,chsh: /usr/bin/zsh: non-standard shell
可以用以下3步解决:which zshthis gives ermyou your path to zsh
Thenchsh -s /bin/zshor replace path to your zsh if different
Restart your machine
添加环境变量,避免出现command not foundopen ~/.bash_profile
将环境变了添加到PATH中,如下export PATH="/Users/dangyan/anaconda/bin:/usr/local/phantomjs/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH"
然后执行下面的语句,打开.zshrc配置文件open .zshrc
找到# User configuration这一行,在下面添加source ~/.bash_profile
�二,至此安装已经完成了。但是终端的用户名变成了
\033[01;33m\][\u@\h ]\033[01;34m\]\W \[\033[01;36m\]$\[\033[00m\]
后来发现是由于以前设置iterm2的颜色的原因:注释掉下列语句就好了:
�
#enables colorin the terminal bash shell
#export export CLICOLOR=1
#sets up thecolor scheme for list
#export export LSCOLORS=gxfxcxdxbxegedabagacad
#sets up theprompt color (currently a green similar to linux terminal)
#export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '
#enables colorfor iTerm
#export TERM=xterm-color
�
�打开文件~/.zshrc,其中有如下行:plugins=(git)
将需要的插件按空格分开,放于此处即可。我的配置如下:plugins=(git extract z d)
修改完后,如果需要在当前shell中生效,需要执行source ~/.zshrc
更多插件请进入 ~/.oh-my-zsh/plugins文件夹探索,也可以看看 wiki 里的 Plugins Overview.
下面介绍一下我的插件:
extract
解压用的 extract 插件,不用记tar的各种参数了。
z
嗯,这也是个自带的但是没有开启的插件。为什么单独把它拿出来讲呢?因为太好用了,没有它我根本就不想用命令行。简直就是可以无脑跳跃,比如你经常进入~/Documents目录,按下 z doc 一般它就可以跳进去了(当然首先你得用一段时间让它积累一下数据才能用)。类似的插件还有好几个比如autojump,fasd,这类东西好像叫 FS Jumping,这里有个完整列表:https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins-Overview#fs-jumping
d
按一下 d 再回车你会看到最近的历史记录,然后你就可以通过数字比如 1, 2 之类的返回到某个历史记录中了。也是非常好用的。
�
转载本文请联系原作者获取授权,同时请注明本文来自金俊杰科学网博客。
链接地址:http://blog.sciencenet.cn/blog-2414991-1104825.html
上一篇:Mac杂记
下一篇:linux/unix 杂记