Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZSH Agnoster Theme showing machine name

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:

enter image description here

enter image description here

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.

enter image description here

like image 815
Drew Avatar asked Feb 13 '15 02:02

Drew


People also ask

How do I customize my zsh theme?

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.


2 Answers

It is the feature according to this; when we are sshing, 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 () { } 
like image 54
hchbaw Avatar answered Sep 30 '22 16:09

hchbaw


Here is my version from first two answers. They explain very clearly. I will merge again.

  1. step 1. open your .zshrc file by vim .zshrc

  2. step 2. go to end of your file.

  3. 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 :)

like image 42
hqt Avatar answered Sep 30 '22 16:09

hqt