一、安装oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
二、修改主题
打开zshrc文件找到ZSH_THEME="robbyrussell"修改为ZSH_THEME=“agnoster”(也可以修改random,这样每次打开一个命令窗口都会随机使用一个主题)
vim ~/.zshrc
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="agnoster"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
修改完退出zshrc文件,再配置生效。
source ~/.zshrc
三、安装历史命令提示插件和高亮插件
下载安装历史命令插件
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
下载安装高亮插件
git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
注意: 如果出现超时,可以试着把git换成https。也可以自行前往git下载解压后放到自己对应的oh-my-zsh的plugins目录下(这里下载后的目录为:/Users/xxx/.oh-my-zsh/custom/plugins)
修改zshrc文件,找到文件中的plugins,修改为
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
四、修改命令行前缀
打开zshrc文件并在末尾添加下面这段内容,YourName为你想修改的名称,可以是符合如🍎
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
# prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
prompt_segment black default YourName
fi
}
修改完退出zshrc文件,再配置生效。
source ~/.zshrc