1. 复制当前的agnoster.zsh-theme
主题,新名称myagnoster.zsh-theme
sudo cp $ZSH/themes/agnoster.zsh-theme $ZSH/themes/myagnoster.zsh-theme
2. 编辑$ZSH/themes/myagnoster.zsh-theme
sudo nano $ZSH/themes/myagnoster.zsh-theme
把prompt_context{}
部分:
从
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
fi
}
改为
prompt_context() {
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
}
如果要显示主机名就改为
prompt_context() {
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER%m"
}
3. 修改~/.zshrc
ZSH_THEME="myagnoster"
然后使其生效:
source ~/.zshrc
参考文献:
How do I hide the “user@hostname” info · Issue #39 · agnoster/agnoster-zsh-theme