You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Terminal doesn't show hostname anymore

Apple changed something in the Terminal for macOS 15. Instead of showing username and localhost name at the prompt, it now shows username@Mac instead. I have tried various commands using sudo scutil to reset the hostname, but nothing seems to work. Anyone have a solution?

Posted on Sep 17, 2024 5:39 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 18, 2024 4:21 PM

Set your three host names, the traditional full name with domain and dots DNS name, the Bonjour mDNS name (less the .local part), and the so-called friendly name Finder and some other displays use.


sudo scutil --set HostName HostName.example.com 
sudo scutil --set LocalHostName HostName
sudo scutil --set ComputerName FriendlyHostName


Restart Terminal.app. Test again.

16 replies
Question marked as Top-ranking reply

Sep 18, 2024 4:21 PM in response to CheeseSamwich

Set your three host names, the traditional full name with domain and dots DNS name, the Bonjour mDNS name (less the .local part), and the so-called friendly name Finder and some other displays use.


sudo scutil --set HostName HostName.example.com 
sudo scutil --set LocalHostName HostName
sudo scutil --set ComputerName FriendlyHostName


Restart Terminal.app. Test again.

Sep 18, 2024 3:51 PM in response to Mark Kaiman

I have the same problem.


user@Mac ~ % sw_vers
ProductName:		macOS
ProductVersion:		15.0
BuildVersion:		24A335


My hostname is set to "cupertino" in System Settings > General > Sharing > Local hostname


My zsh prompt is configured correctly:

user@Mac ~ % grep PROMPT < .zshrc
PROMPT='%n@%m %~ %# '


The hostname command just says "Mac"


user@Mac ~ % /bin/hostname -f
Mac


networksetup  seems to give the Find My Mac computer name of "MacBook Pro"


user@Mac ~ % networksetup -getcomputername 
MacBook Pro


Only scutil LocalHostName gives an "okay" answer to LocalHostName.


user@Mac ~ % scutil --get ComputerName 
MacBook Pro


user@Mac ~ % scutil --get HostName     
HostName: not set


user@Mac ~ % scutil --get LocalHostName 
cupertino


Oct 21, 2024 11:40 AM in response to rodmur

I fully agree this is not "only" a terminal issue : after upgrade to version 15 my computer name has changed by itself also on external services that get my machine name from outside, and not only on the terminal prompt : I use boinc and my machine name has changed to "imac" on my boinc projects accounts, and this name is not visible on network share name parameter or general machine name.

Sep 17, 2024 6:25 PM in response to Mark Kaiman

Mark Kaiman wrote:

Apple changed something in the Terminal for macOS 15. Instead of showing username and localhost name at the prompt, it now shows username@Mac instead. I have tried various commands using sudo scutil to reset the hostname, but nothing seems to work. Anyone have a solution?


?

I saw no change, You can customize the prompt like always:

MacBook-Pro ~ %



Need the extra verbiage?


See if this returns the default prompt (note the trailing blank space) copy and paste:

export PS1="%n@%m %1~ %# " 


Using a VPN(?)

you can read more, ref VikingOSX post:

How to make terminal to follow local host… - Apple Community


Sep 18, 2024 4:50 PM in response to CheeseSamwich

CheeseSamwich wrote:

Thanks MrHoffman, this workaround worked for me. I do want to emphasize that this is a bug, and that System Settings > General > Sharing > Local hostname should still work the same way it has for at least the last 10 years, but it doesn't.

I’ve never seen the local host name in the prompt. It has always been the computer name.

Sep 18, 2024 5:27 PM in response to Mark Kaiman

Mark Kaiman wrote:

Didn't work for me.


So to confirm, you’ve reset all three values, …

and have restarted Terminal app, …

and %m in the prompt doesn’t show the expected result?


Have you confirmed your PS1 matches what was shown?


If you issue “get” commands on those three settings, are they each returned as was updated?


Tried a restart, on the off chance the local DNS cache is not playing well.


What does a dig +short command show for the local IP host address? (Yeah, dig uses a somewhat different DNS resolver path and bypasses the local cache.)


PS: “didn't work for me” and its variations are phrases I would encourage purging from any problem reports.

Oct 4, 2024 10:31 AM in response to Mark Kaiman

This is more than just a terminal issue, the hostname I was using for my laptop prior to MacOS 15 was replaced with "MacBookPro", and that is all my FiOS router sees no matter how many scutil commands I use to try to change it back. Upgrading to 15.0.1 did not help. So somewhere, there is a hostname setting that I can't touch, I have yet to find it.

Oct 5, 2024 10:41 AM in response to Mark Kaiman

Depending upon whether you are using Bash or Zsh shells the Terminal prompt syntax varies and expecting the wrong shell could alter the PS1 results. To see the PS1 prompt special characters section of the respective Shell manual


Bash v5.2.37(1)

mandoc  -l  /opt/homebrew/share/man/man1/bash.1  |  col -b  |  awk  '/^PROMPTING/,/^READLINE/  {print}'  |  more
mandoc  -l  /usr/local/share/man/man1/bash.1  |  col -b  |  awk  '/^PROMPTING/,/^READLINE/  {print}'  |  more


Bash v3.2.57(1)

mandoc -l /usr/share/man/man1/bash.1 | col -b | awk '/^PROMPTING/,/^READLINE/ {print}' | more


Zsh v5.9

mandoc -l /usr/share/man/man1/zshmisc.1 | col -b | awk '/^EXPANSION OF PROMPT SEQUENCES/,/^zsh/ {print}' | more



Terminal doesn't show hostname anymore

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