Prevent the Terminal host name from changing
The computer's hostname as shown in the terminal may change. Here's how to change it back and prevent that from happening.
When you launch the terminal, the default shell "Bash" will present the last login time, followed by the command prompt. This is formatted to show the computer's name, followed by the current directory and then a dollar sign. Depending on the system and network configuration, the computer's name may change.
The computer's host name is the one you type in the "Sharing" system preferences, and while a change in the hostname should not affect the performance of the machine, it is nice to have it be consistent. The first thing to try is to use the "hostname" command to change the hostname:
After running this command, the terminal name will not change until you quit the current shell and log in again:
The hostname can be changed dynamically by routers and other network devices through DHCP requests, which can have the hostname keep changing every time your IP address and other DHCP information is renewed. If this is the case, you may be able to set the router to never provide hostname information, or you can set the computer to never accept a hostname change. To do this, you will need to add a line to the computer's hostconfig file using the following procedure:
Open the Terminal
Enter the following command:
sudo pico /etc/hostconfig
Authenticate, scroll to the bottom of the file, and add the following line:
(Change "Tophers-Desktop" to your desired hostname--no spaces)
Save the file and quit by pressing control-X, confirming the save with the "Y" key followed by "enter".
After this has been added to the file, the computer's hostname should not change even when you renew your DHCP lease.