#enables colorin the terminal bash shell export
export CLICOLOR=1
#sets up thecolor scheme for list export
export LSCOLORS=GxFxCxDxBxegedabagaced
#sets up theprompt color (currently a green similar to linux terminal)
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
在 ~/.zshrc 文件中添加语句: [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
Add the following line to your ~/.bash_profile or ~/.zshrc file (and remember
to source the file to update your current session):
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
设置高亮模式
~/.bash_profile
文件安装其它主题
以安装 Dracula 为例: https://draculatheme.com/iterm/
使用 zsh
cat /etc/shells
命令查看已经安装的 shell安装 iTerm 后,使用一下命令把 bash 切换成 zsh ,重启 iTerm (或新建一个窗口)后即可使用 zsh :
zsh 切换回 bash ,同理:
安装 oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
chsh -s /bin/zsh
chsh -s /bin/bash
注:另一种安装方式:wget 自动安装:
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
安装 oh-my-zsh 时,它自动读取你的环境变量并且自动帮 zsh 进行设置on-my-zsh 主题之绝对路径
oh my zsh 提供了数十种主题,相关文件在 ~/.oh-my-zsh/themes 目录下,默认主题是 robbyrussell 。修改默认主题,显示绝对路径:把
c
改为d
,c
表示当前目录,d
表示绝对路径,另外在末尾增加了一个>
。on-my-zsh 插件
一、安装自带插件
oh my zsh 开源项目提供了完善的插件体系,相关的文件在 ~/.oh-my-zsh/plugins 目录下,默认提供了100多种。插件在 .zshrc 里配置,找到 plugins 关键字,添加需要的插件即可,插件之间用空格隔开,系统默认加载 git ,如下:
plugins=(git osx python)
source ~/.zshrc
二、安装 zsh-syntax-highlighting 语法高亮插件
brew install zsh-syntax-highlighting
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
(因为 zsh-syntax-highlighting 下载在 /usr/local/share/ 目录中,并不是在 oh-my-zsh 自带的 ~/.oh-my-zsh/plugins 插件目录中,所以使用以上的插入语句,而不是plugins=(git osx python zsh-syntax-highlighting)
)source ~/.zshrc
三、安装 autojump 快速切换路径插件(方法同上)
brew install autojump
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
Add the following line to your ~/.bash_profile or ~/.zshrc file (and remember to source the file to update your current session): [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.shsource ~/.zshrc
注:虽然 oh-my-zsh 提供了很多插件,但大量的插件会拖慢打开的速度,因此只安装常用的就好了。
参考:MacTalk - 终极 shell
附:iTerm 保持 ssh 连接不断线
参考:
在本地环境中编辑或创建
~/.ssh/config
文件,增加:300
是发给服务端心跳的间隔,单位是秒,根据你自己的服务器情况设置。6
是最多发送的次数,如果想一直保持连接,本项可以不写。