Macbook Pro Terminal Showing IP Location Instead of My Device or Localhost Name After @ Symbol

Hi, my name is Antonius, and right now I have been using my Macbook Pro M1 Pro since July 2022. I am a computer science student and I kind of doing software engineering and development things.


Since the first time I used my MBP, I have been considering why my terminal is showing my IP instead of my Mac Name.


When opening the terminal, what is shown is


username@192 ~ %


Which what others shown is


username@name's MBP ~ %

or

username@name's MacBook Pro ~ %


When I do some research, 192.xxxxxxxxx is my IP Address. I have been curious about how to change this into my LocalHost Name, I have tried several ways including changing the name in System Preferences >> Sharing >> Change LocalHost Name and Device Name.

Some people suggest to create some .profile or .bashprofile, but it didn't work. Even when I opened the Terminal Preferences, the Root Directory name is not my Device Name but written with the IP Address.


Functionally, the terminal works and still can do many things, but in my own perspective, it is a little bit disturbing.


So if anyone knows or could help me with some solutions that won't ruin my Mac or need too many computation stuff to be done, let me know and share your experience

MacBook Pro 16″, macOS 12.5

Posted on Aug 8, 2022 08:36 AM

Reply

Similar questions

1 reply

Aug 8, 2022 09:16 AM in response to antoniuskevin15

Your shell prompt string is pulling in the reverse DNS (address to host name) translation for your IP address as the host name, and what you see is what you got back from whatever server is serving your DNS responses here.


The PS1 bash prompt stuff will work if you’re using the bash command shell, but I’d guess you’re using zsh here as you’re probably using a more recently-created login, and the PS1 prompt and zsh shell and shell login and logout scripts are named differently and work a little differently than those of bash.


bash: https://kaushaldokania.github.io/posts/2020/02/how-to-customize-linux-ps1-bash-prompt/


zsh: https://voracious.dev/blog/a-guide-to-customizing-the-zsh-shell-prompt


The host name (DNS name) and local host name (mDNS name) and the “friendly” computer name used for Finder and some other displays are all set in System Preferences > Sharing, or can be set or shown from the command line.


To see or set the names from the command line, see:


man scutil


See HostName, LocalHostName, and ComputerName, etc.


192.168.0.0/16 is the smallest of the three blocks of IP addresses reserved for and commonly used for NAT’d networks. There are also three blocks reserved for documentation and for forum postings and testing, too. 192.0.2.0/24 is one. This is useful for posting around here.


And FWIW, the phrase “doesn’t work” is best considered reserved for end-users only. What you tried, what happened, what versions are in use, what error messages or diagnostics were shown if any, details matter to app developers and to IT folks. As you develop and support apps and servers, well, we all come to appreciate receiving these sorts of details, or a standalone reproducer, or other such problem reports.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Macbook Pro Terminal Showing IP Location Instead of My Device or Localhost Name After @ Symbol

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.