Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to return terminal prompt to default?

I've recently noticed my terminal prompt seems to indicate the IP address of my cable router.


I say recently, since I did have some Internet problems which were solved after powering down the router and removing the battery for a few minutes. Since then, the prompt has been:


Last login: Mon Dec 26 18:27:44 on ttys000

d24-235-195-133:~ user$


Is there a way to return it to a 'default' prompt, and second, why did it change?

--

Many thanks.

iMac, Mac OS X (10.7.2)

Posted on Jan 1, 2012 9:42 AM

Reply
27 replies

Jan 1, 2012 2:55 PM in response to baltwo

There is nothing particularly wrong with your disk, your Mac computer, configuration nor any other aspect of the system.


The default shell prompt is based of your hostname, and you're currently acquiring your hostname off your ISP's or some other local DNS set-up. Quite possibly from something your (somewhat flakey?) router is dredging up from somewhere.


If you want to customize your terminal prompt (which is the easiest way to get exactly what you want), then set the PS1 symbol in your bash login procedure, exit the session, and start another session.


Details on customizing your bash shell prompt are available here, among other places.


Fixing your router or your local DNS responses (if that DNS is something you have control over) is another and different discussion; you're probably not running DNS services for your LAN, but there may well be other issues with your LAN (and around why you've been resetting the configuration, etc).

Jan 1, 2012 3:02 PM in response to MrHoffman

Thank you MrHoffman. I've went through the Disk Utility procedures to Verify Disk and Permissions and all seems fine. I'm sure it is related to my recent power-down cycle of the router.


However, I hesitate to reinstall the OS merely to get back my shell prompt. I will follow up your suggestion to edit my profile and set it the way I want. It's only a shell prompt after all 🙂


Thank you all for your time and suggestions. As far as I am concerned this thread has been solved.

Jan 1, 2012 5:18 PM in response to MouthBreather

MrHoffman is 100% correct. Disk Utility repair permissions, verify (or even repair) have absolutely nothing to do with the prompt you are getting.


And reinstalling Mac OS X will change nothing, as the problem, as MrHoffman explained, has nothing to do with your Mac. It is your router and/or your ISP.


The bash shell always does a reverse DNS lookup on your Mac's IP address to get your computer name. The Mac's DNS lookup service does not get a result from the DNS servers, it will use your computer name as specified in System Preferences -> Sharing. In your case, prior to restarting your cable modem, the DNS lookup did not return anything, so your sharing computer name was used. After the cable modem restart, the DNS lookup started returning a result so bash used that information.


Chances are it is a lot more work than it is worth trying to get the DNS lookup to stop returning a value, so it is easier to just change your PS1 shell variable and get on with life.


You could even use the following to always get your sharing computer name


PS1='$(networksetup -getcomputername):\W \u\$ '

Jan 1, 2012 6:32 PM in response to BobHarris

I believe you are right, and I also believe it is the router / DNS resolution causing all this.


I tried your suggestion but can only get it to work in the current shell session using

export PS1='$(networksetup -getcomputername): \W \u$ '


If I try to 'sudo nano .bashrc' and enter the line, it doesn't seem to have any effect.


Thank you for continuing to work on this.

Jan 1, 2012 6:41 PM in response to MouthBreather

bacause .bashrc is ONLY excuted when starting a sub-shell. It is NOT execute when starting a login shell.


bash when run as a login shell will look for one of the following initialization scripts and use the first one it sees:


.bash_profile

.bash_login

.profile


Other bourne shell variations will also use .profile if they do not fine their personalized flavor of initialization script.

How to return terminal prompt to default?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.