Mr. Medeiros Mr. Medeiros - 1 year ago 72
Bash Question

Command line not displaying Computer name

I was hoping someone could tell me why I can getting an odd sequence of numbers and letters usually where my computer name is within the terminal. I have checked to naming on the computer (System Preferences > Sharing), which is reading " Medeiros Macbook Pro." Rather than getting this though I get the following within the terminal:

Last login: Wed Jul 6 10:23:49 on ttys000
ACA80A7A:~ medeiros$ "

Similarly, when I use git log, I get information about the author as "". Any information on how I can resolve this would be greatly appreciated!


Answer Source

In comments you reported that your prompt string ($PS1) is "\h:\W \u\$". Each digraph consisting of a backslash (\) followed by another character is a code representing a piece of information about your machine and environment; the remaining characters represent themselves. The meaning of the codes is covered in the Bash manual; the ones relevant to you are:

  • \h: the first segment of the hostname

  • \W: the basename of the working directory, except that your home directory is abbreviated as a tilde (~)

  • \u: your username

  • \$: a # if your effective user id is 0 (root's), otherwise a $

Thus, the "odd sequence" you asked about, evidently "ACA80A7A", is the first segment of the hostname of your computer. This is also evident in the email address you presented.

If your PS1 has not changed but your prompt has, then your machine's hostname has changed. This very likely arises from turning on network autoconfiguration (i.e. DHCP), just as @chepner suggested in comments.