1.编辑$ZSH/themes/agnoster.zsh-theme
sudo nano $ZSH/themes/agnoster.zsh-theme
prompt_context{}
部分默认在非default用户的时候,显示用户名和主机名:
从
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}%}.)%n"
}
如果仅显示主机名就改为
prompt_context() {
prompt_segment black default "%(!.%{%F{yellow}%}.)%m"
}
2. 生效
使其生效:
source ~/.zshrc
参考文献:
How do I hide the “user@hostname” info · Issue #39 · agnoster/agnoster-zsh-theme