1. 打开 ~/.zshrc 文件
vi ~/.zshrc
2. 在文件中找到当前使用的 oh-my-zsh 主题名:
ZSH_THEME="agnoster"
这里用的主题名是agnoster
3. 打开 oh-my-zsh 主题目录,根据主题名,找到主题文件:
cd ~/.oh-my-zsh/themes
vi agnoster.zsh-theme
4. 修改主题文件:
按i修改文件
- 隐藏用户名
prompt_context() {
if [["$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT"]]; then
# prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
fi
}
- 隐藏全路径,只显示当前路径
prompt_dir() {
# prompt_segment blue $CURRENT_FG '%~' # show full path
prompt_segment blue $CURRENT_FG '%c' # show only current word folder
}
这里可以直接修改 '%~' 为 '%c'
'%~'表示全路径,'%c'表示当前路径