Skip to content

Instantly share code, notes, and snippets.

@benmatselby
Created June 2, 2014 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmatselby/ea718b27a23b7fd16aaa to your computer and use it in GitHub Desktop.
Save benmatselby/ea718b27a23b7fd16aaa to your computer and use it in GitHub Desktop.
Setting hostname on a mac
With all the machines I now use, and the fact I’m getting older and my memory is going, I needed to add hostname into my bash prompt for the first time, and came across a little issue on Apple’s Mac OS X Mountain Lion.
When I updated my PS1 setting I was getting:
```
(null):~
```
Not so good. I was also getting similar responses when I was running “hostname” on the command line.
I’ve now found out how to resolve this issue on Mountain Lion:
```
$ sudo scutil --set HostName [Your Hostname]
```
This will now allow you to use “\h” in your PS1 setting and give you the correct result when running “hostname”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment