I have a development server hosted on Digital Ocean, using Ubuntu 14.04. I switched my shell to ZSH and decided to go with the Agnoster theme. In order to get user@hostname
to stop showing, I set the DEFAULT_USER
in my .zshrc file.
For some reason on the ubuntu server, that's not working. The hostname still shows, and will not go away. I'm doing the exact same thing on my Mac OSX, and it works fine.
Here are some screenshots:
Anyone know what's going on? I even tried DEFAULT_USER="$USER@$HOST"
with no luck.
If I go back to the default, Robby Russell theme, it works just fine.
To change the Theme, simply change the ZSH_THEME value in ~/. zshrc file from robbyrussell to Avit. Run the following command to update the config. Open ITerm2 > Preferences > Profiles > Colors and change the background black color to use 20% gray as shown below.
It is the feature according to this; when we are ssh
ing, the hostname will be shown.
Overriding the function prompt_context
or build_prompt
on Agnoster theme will rescue. Putting below snippets at the very end of the ~/.zshrc
for example.
# redefine prompt_context for hiding user@hostname prompt_context () { }
Here is my version from first two answers. They explain very clearly. I will merge again.
step 1. open your .zshrc
file by vim .zshrc
step 2. go to end of your file.
Paste this code:
careful indent again your code
prompt_context() { if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then prompt_segment black default "%(!.%{%F{yellow}%}.)$USER" fi }
Reference link: agnoster theme code
Hope this help :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With