# ugly terminal prompt?



## boxlight (Apr 22, 2007)

I recently did a full reinstall of OS X on my Mac (updated to 10.4.9).

When I launch terminal, the prompt says this:

"Welcome to Darwin!
cpe0016cb894156-cm000a735f6199:~ stephen$"

My question is, what is this "cpe0016..." stuff? It's pretty ugly. Shouldn't it say "localhost" or something like that?

Any help is greatly appreciated!


----------



## symphonix (Apr 23, 2007)

It uses the computer name, I think. On a fresh install, the computer name is usually a string of near-nonsense. Go into System Preferences -> Sharing and change the computer name there.


----------



## michaelsanford (Jun 22, 2007)

Many ISPs assign a host name to your computer; the variable in the bash prompt will use that. "cpe0016cb894156-cm000a735f6199" looks very much like an assigned hostname.

The way to fix that isn't to change the hostname, because it is just being 'over-ridden' (not really, but you get the idea) by the ISP. What you should do is change the text in the prompt itself:
Change

```
PS1='\h:\w \u\$ ';
```
to

```
PS1='Pretty host name:\w \u\$ ';
```
in /etc/bashrc or in ~/.profile


----------



## boxlight (Jun 22, 2007)

>PS1='Pretty host name:\w \u\$ ';
>---------
>in /etc/bashrc or in ~/.profile


OUTSTANDING!  Thank you very much for that.  Works like a charm.


----------



## artov (Jun 29, 2007)

I use zsh command shell and have "%M%# " as PS1 (I guess it same as \h\$
on bash). But, zsh has function precmd(). It is evaluated before the prompt
is printed. I have following as my precmd():

function precmd() {
   echo -n "\e]2;${PWD} (${HOST})^G"
}

(The ^G is actually character Ctrl-G).

So what does this do? In zsh prompts are evaluated in terminal mode, where
most control characters do nothing. But, the precmd() is evaluated in mode
where control characters are evaluated. The \e]2; (\e is ESC character)
tells the terminal to store the current cursor position. and start to output
to window title. The Ctrl-G returns the cursor back. So, I have on each
terminal window (this works on X-Window terminals also, so I use the
precmd() on Linux also) the name of the current directory and the computer
name. 

You might ask why I don't remember the computer name. If I take
ssh connection to another computer, all I have to do is look is the window 
title to check on which computer I am.
to


----------

