Hostname changes in the terminal when connecting to some wifi networks
On Lion (at least), the best way to achieve this is by running scutil:

sudo scutil --set HostName NAME


replacing NAME with the hostname you want. Note that /etc/hostconfig is deprecated, if you can believe a comment at the top of the file.