zsh 配置

查看已安装shell

cat /etc/shells查看Mac上已有的shell,一共有6中

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

chsh -s /bin/zsh 更改使用的shell种类,输入Mac密码来确认更改shell种类,退出终端,重新进入即可。
注意:由bash切换到zsh后.bash_profile里面的环境变量的配置便不生效了,需要在~/.zshrc中重新配置。

下载 iTerm2

官方网址,www.iterm2.com

安装 oh_my_zsh

oh_my_zsh 是对主题的进一步扩展

cd
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

配置 zsh

# 扩展
plugins=(git mvn)

# 隐藏用户名和主机名
# prompt_context() {}

# 只保留用户名,隐藏主机名
prompt_context() {

  DEFAULT_USER='duzhongyu'

  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$DEFAULT_USER"
  fi
}

# 只保留主机名,隐藏用户名
# prompt_context() {
#   if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
#     prompt_segment black default "%(!.%{%F{yellow}%}.)$HOST"
#   fi
# }

设置zsh登陆提示

修改 /etc/motd 文件,即可修改shell登录提示。motd(意思是:message of today)

cat /etc/motd
vim /etc/motd



        _____                    __              __                ______  ______
       /\___ \                  /\ \___         /\ \              /\__  _\/\__  _\
       \/__/\ \   __  __    ____\ \  ,_\        \_\ \     ___     \/_/\ \/\/_/\ \/
          _\ \ \ /\ \/\ \  /',__\\ \  \/        /'_` \   / __`\      \ \ \   \ \ \
         /\ \_\ \\ \ \_\ \/\__, `\\ \  \_      /\ \l\ \ /\ \l\ \      \_\ \__ \ \ \
         \ \____/ \ \____/\/\____/ \ \___\     \ \___,_\\ \____/      /\_____\ \ \_\
          \/___/   \/___/  \/___/   \/___/      \/__,_ / \/___/       \/_____/  \/_/    .


你可能感兴趣的:(zsh 配置)