2

In my terminal app, it shows

(base) jeffsungs@Sung-Macbook-Air ~ %

on every row. I know that Sung-Macbook-Air is the localhostname, and how to change it. But how about the writings before the @ (in this case is jeffsungs), what is its name and how to change it?

2

2 Answers 2

4

This information is generally referred to as the prompt.

While there are differences between the various shells like bash and zsh, generally speaking you can set prompt options by modifying the shell variable PS1.

In bash start by looking at your current (default) prompt:

$ echo $PS1

You'll likely see \u which is the argument for the current user.

Set PS1 to your liking and then export to your .bash_profile or .zshrc - I prefer a more compact one: \h:\W \u\$

0

The name before the "@" is the user who is logged in. You can't change that unless you change to another user. The name after the "@" is the localhost determined by Apples's bonjour technology.

To change to the hostname, you could use the following command (as the super user)-

scutil --set HostName name-of-host
4
  • 2
    Isn't changing the part before @ rather simple by redefining PS1?
    – nohillside
    Apr 28, 2022 at 13:24
  • To what? A static name? Both $USER and $LOGNAME are set by login and usually cannot be changed.
    – fd0
    Apr 28, 2022 at 13:33
  • 1
    Why was this answer downvoted? It's accurate. Someone who only uses the face bubbles to log into their Mac may not realize that the OS assigned a username to them. Apr 28, 2022 at 13:43
  • 2
    There are two ways one can read the "You can't change that unless you change to another user." part: a) you can't change your account name (so yes) or b) you can't change the text in the string (which you can by changing PS1). Given the level of knowledge shown in the question it may help to elaborate on this in an answer.
    – nohillside
    Apr 28, 2022 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .