Hostname problem

tag

macrumors 6502a
Original poster
Apr 29, 2005
918
9
Ok, Im trying to find a way to fix this, or get around it, depending how you look at it.
When I connect to the internet, my host name of my iMac changes.

Prior to connection to internet it is 'Robs iMac'...
rob@Robs iMac:~ $ uname -a
Darwin Robs iMac 8.1.0 Darwin Kernel Version 8.1.0: Tue May 10 18:16:08 PDT 2005; root:xnu-792.1.5.obj~4/RELEASE_PPC Power Macintosh powerpc

Now after I connect it changes to my IP host address...
rob@user216-178-86-223:~ $ uname -a
Darwin user216-178-86-223.netcarrier.net 8.1.0 Darwin Kernel Version 8.1.0: Tue May 10 18:16:08 PDT 2005; root:xnu-792.1.5.obj~4/RELEASE_PPC Power Macintosh powerpc

Now this isn't a huge problem, but if I connect to this computer via ssh or the like, I would like to have the computers name in the command line prompt, so I can tell which system I am on, but I can't seem to find a way to do that since whenever I connect to the internet, its host name automatically changes to its IP address.

Currently I am using this prompt... PS1='\u@\h:\w \$ '

I suppose if it comes down to it I could just manually put in the hostname and keep it static, but I would like to see if I can make it so the hostname isnt changing everytime I log on.
 

peterparker

macrumors regular
Mar 12, 2005
247
0
Houston
Strange, it was controlled in /etc/hostconfig in Panther but not in Tiger. I'll look around somemore or maybe someone else will have the answer first.
 

daveL

macrumors 68020
Jun 18, 2003
2,425
0
Montana
When you connect to the internet your ISP is assigning you a host name and IP address via DHCP, which overrides your local settings. At least that's how it looks from here.
 

tag

macrumors 6502a
Original poster
Apr 29, 2005
918
9
Alright then thanks everyone, guess I'll just be changing the prompt manually then.
 

tag

macrumors 6502a
Original poster
Apr 29, 2005
918
9
superbovine said:
http://www.magnux.org/doc/howto/en/Bash-Prompt-HOWTO-12.php

section 12.5 maybe of some interesting. you could probably modify to suit your needs.

Ok thats just cool, color coding your prompt via what type of connection you are using. I modified it so that it checks for a file on each system, and color codes the prompt based upon which file it finds, though after using it for a bit, I found the color coding actually works more efficiently to tell me which way Im connected (ie. ssh, telnet, via root/user color combinations). So thanks for that snippit.