Otaqui.com Blog

OS X Terminal Prompt showing a different name to the Computer Name

My mac terminal came with a default prompt which looked like this:

Vigor:~ pete$ 

I had changed my computer name to something I preferred, which works fine for browsing to your own apache server, but this did not have any effect on thebash prompt. I also wasn’t (yet) interested in customising the prompt with a bashrc file as suggested all over the web.

It turned out that the terminal was showing the hostname of the machine, not the computer name. You can set the hostname with the following snippet:

$ sudo hostname whatever-you-want

This would give you a prompt like this:

whatever-you-want:~ pete$

UPDATE: the above method does not permanently change the hostname. It will revert once you reboot. I’ve tried another method which seems better:

$ sudo scutil --set HostName whatever-you-want.example.com