3

I installed ZSH today and whenever I use it, my hostname changes.

Outside of ZSH it is:

mus@MyMachine

However, when I run zsh it then displays as:

mus@x86_64-conda_cos6-linux-gnu

I have searched for a reason online but can't seem to find anything that addresses it.

When I try hostname (whilst running ZSH) to check if it has been changed, it returns:

MyMachine

This indicates that my hostname hasn't changed, yet it still displays as:

mus@x86_64-conda_cos6-linux-gnu

It takes up a lot more screen space than I would like and makes my CLI messy, which is why I would like to change (or even revert) it if possible.

Why is this happening? Is this something I can / need to change?

  • You can configure your zsh prompt as you like http://zsh.sourceforge.net/Intro/intro_14.html – Stephen Boston Nov 16 '19 at 22:00
  • Okay, I'll look into that. The main thing I want to know is why it changed in the first place. – MusTheDataGuy Nov 16 '19 at 22:04
  • @MusTheDataGuy Your hostname didn't change. When you install a new shell like zsh, or fish, they will have their own way of displaying a prompt. Some show the directory, some don't. Some show the hostname, some don't. There are plenty, of resources on the internet how to change it. – darksky Nov 17 '19 at 03:36
  • @darksky That's the thing; as I highlight a number of times in my question, I didn't think that the hostname had changed. What I wanted to know was why it was displayed as something other than what I knew it to be. Since posting, however, I have read a lot on the matter and I now understand why this happened. Also, change your comment to an answer and I'll accept as this is helpful nonetheless. – MusTheDataGuy Nov 17 '19 at 07:04
  • @MusTheDataGuy okay, see my answer for more detail. – darksky Nov 17 '19 at 20:23

1 Answers1

0

What you're referring to is called a prompt. Every shell has their default way of displaying this. For Bash, it is

username@hostname:/current/working/directory$

When you run ZSH for the first time, you should get a menu asking you to create a configuration. By selecting (2) to populate your ~/.zshrc with the recommended configuration, you'd get the default prompt that looks like

username@HOST /current/working/directory
 % 

Note that in addition to hostname which is the name of your machine, there is such a thing as HOST environment variable. You can print it by echo $HOST. This is what you see in your ZSH prompt. In you case, it seems you've installed Anaconda, and according to this, this variable gets set to x86_64-conda_cos6-linux-gnu after a conda environment activation. You can of course manually reset it back by adding

export HOST=$(hostname) 

to the end of your ~/.zshrc.

One of the most well known and elaborate ways to customize the ZSH prompt is using what's called Oh-My-ZSH. As you can find on their website, it is installed simply by

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

You will find that with Oh-My-ZSH, the possibilities with customization are endless. Here you can find many themes to choose from.

darksky
  • 972