Ben
Ben

Reputation: 525

What does the string at the beginning of a ZSH commandline mean?

The commandlines in my terminal begin with my username and a string of letters, numbers and dashes:

ben@u-081-c214 ~ % 

I understand that ~ is the path (in this case my home directory), and I guess that % means the end of that string and that the shell is waiting for my input (similar to the $ in bash), but what does the rest of the string mean?

Lines in bash used to begin with the shell name and version number:

bash-3.2$ bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin24)
Copyright (C) 2007 Free Software Foundation, Inc.
bash-3.2$

Lines in zsh don't:

ben@u-081-c214 ~ % zsh --version
zsh 5.9 (arm64-apple-darwin24.0)
ben@u-081-c214 ~ %

So what does that string mean? I'm on a Mac if that makes a difference.


Also, what is the name for the whole of this string before the user input (ben@u-081-c214 ~ % or bash-3.2$)? I have been searching the internet for an answer to my question, but without knowing that name I couldn't find anything related to it.

Upvotes: -3

Views: 48

Answers (2)

amrita yadav
amrita yadav

Reputation: 161

ben@u-081-c214 ~ % is your zsh Prompt. And

  • ben : This is your username.
  • u-081-c214 : This is your hostname, which is the name of your computer on the network.
  • ~ : ~ means your home directory (/Users/ben).
  • % : The default prompt symbol in zsh.

(In bash, the prompt typically ends with $ (for normal users) or # (for root))

  • In zsh, % is used instead of $.

Upvotes: 1

choroba
choroba

Reputation: 242123

It's called "prompt" and its contents depends on the value of the special variable $PS1.

The string u-081-c214 is most probably the expansion of %m, i.e. the machine name (hostname).

Upvotes: 2

Related Questions