安装zsh和oh my zsh详细配置
Linux及Mac基本安装
Linux 下,先安装zsh
echo $0
# -bash
# 安装 zsh
yum install -y zsh
切换到Zsh
#切换到ZSH
chsh -s /bin/zsh
cd ~
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
cp ~/.zshrc ~/.zshrc.orig
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc
自动补全插件
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
vim ~/.zshrc
ZSH_THEME="agnoster"
plugins=(git extract z sudo zsh-autosuggestions zsh-syntax-highlighting)
source ~/.zshrc
在 Mac 下额外配置一下 iterm
安装PowerLine
sudo easy_install pip
pip install powerline-status --user
安装字体
mkdir ~/Desktop/temp
cd ~/Desktop/temp
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
安装好字体库之后,我们来设置iTerm2的字体,具体的操作是iTerm2 -> Preferences -> Profiles -> Text,在Font区域选中Change Font,然后找到Meslo LG字体。有L、M、S可选,看个人喜好
安装配色
cd ~/Desktop/temp
git clone https://github.com/mbadolato/iTerm2-Color-Schemes
导入全部配色方案
进入iTerm2 -> Preferences -> Profiles -> Colors -> Color Presets->import 把 iTerm2-Color-Schemes/schemes 目录下的配色方案都导入进来。
在 Color Presets 里选择一个喜欢的方案。比如:
The Hulk
Solarized Dark Higher Contrast
如果只想显示一层路径
vim ~/.oh-my-zsh/themes/agnoster.zsh-theme
把下面代码里的%~修改成%1d 即可
prompt_dir() {
prompt_segment green $CURRENT_FG '%~'
}
如果要关闭路径显示
vim ~/.oh-my-zsh/themes/agnoster.zsh-theme
搜索 build_prompt
把 prompt_dir 屏蔽掉,如下:
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
prompt_aws
prompt_context
#prompt_dir
prompt_git
prompt_bzr
prompt_hg
prompt_end
}
安装主题(应该可以不用安装)
cd ~/Desktop/temp
git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
cd oh-my-zsh-agnoster-fcamblor/
./install
异常解决
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x 3 root root 96 6 24 21:46 /usr/local/share/zsh
drwxrwxr-x 4 root root 128 6 24 21:49 /usr/local/share/zsh/site-functions
chmod g-w,o-w /usr/local/share/zsh
chmod g-w,o-w /usr/local/share/zsh/site-functions
追加额外的配置
在头部添加
vim ~/.zshrc
alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
export GOPATH=/Users/mark/Desktop/work/data/apps/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
#export GOPROXY=https://goproxy.io
# Custom Add not System. Make the command line can use Shadowsocks proxy.
function proxy_off(){
unset no_proxy
unset http_proxy
unset https_proxy
echo -e "已关闭代理"
}
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:1087"
export https_proxy=$http_proxy
echo -e "已开启代理"
}
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.zshrc
让 Macos 自带终端不乱码
终端->"偏好设置"->"描述文件"->"文本"->"字体"->所有字体里选一个合适的带Powerline后缀的字体