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