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.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

The Terminal shows device MAC address instead of device name

When using zsh, one might see the terminal show this line:

[username]@[device-name] [working-dir] %

But on my MacBook Pro, the shell shows the device's Mac address instead, occurring every time I use the terminal.

How can I deal with it and make it show the device name?

MacBook Pro 13″, macOS 13.4

Posted on Jun 29, 2023 4:58 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 29, 2023 6:29 AM

The Bash and Zsh terminal prompts (PS1) use different syntax:


Use the following in your ~/.zshrc file:


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

viking@odin ~ %


Reference: Zsh 13 Prompt Expansion


If you do VPN connections and don't want your hostname changed to a dynamic string by the VPN domain name server, you could do the following to retain your local hostname at all times:


MyHost="$(networksetup -getcomputername)"
PS1="%n@${MyHost}: %~ %# "





Similar questions

2 replies
Question marked as Top-ranking reply

Jun 29, 2023 6:29 AM in response to Yushu145

The Bash and Zsh terminal prompts (PS1) use different syntax:


Use the following in your ~/.zshrc file:


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

viking@odin ~ %


Reference: Zsh 13 Prompt Expansion


If you do VPN connections and don't want your hostname changed to a dynamic string by the VPN domain name server, you could do the following to retain your local hostname at all times:


MyHost="$(networksetup -getcomputername)"
PS1="%n@${MyHost}: %~ %# "





The Terminal shows device MAC address instead of device name

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