当前位置:网站首页>Zsh hides the user name and host name in front of the command line

Zsh hides the user name and host name in front of the command line

2020-11-10 18:05:00 diyxiaoshitou

modify vim ~/.zshrc file , Add... At the bottom of the file

Hide user name and host name
prompt_context() {}
Keep only the user name , Hide host name


1.  prompt_context() {
    
2.    if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    
3.      prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
    
4.    fi
    
5.  }
    

Keep only the host name , Hide user name


1.  prompt_context() {
    
2.    if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    
3.      prompt_segment black default "%(!.%{%F{yellow}%}.)$HOST"
    
4.    fi
    
5.  }
    

Remember to execute after modification source ~/.zshrc

版权声明
本文为[diyxiaoshitou]所创,转载请带上原文链接,感谢