The OS X bash shell (Terminal.app) prompt string
The OS X Terminal prompt string — what you see when you launch Terminal.app — is constructed from a couple of different pieces of information, using typical bash mechanisms.
The terminal prompt string can include your default directory, and it can include the reverse DNS information for your local Mac, as provided by your router or your DNS server.
Reverse DNS is a translation of your IP address to the host name, and that might be a readable name, or some string constructed from your IP address; it probably won't be what you expect. Confusingly, this string can vary, based on whatever your current DNS server or your local gateway router is returning.
If you have something unexpected or weird showing up in your Terminal.app prompt, it's probably a string that was acquired from your current reverse DNS.
Unless you've been working with your PS1 string, that is. If you're doing that, you're on your own, there.
Given that the question of a potentially hacked OS X system does occasionally arise in some conversations of unexpected prompt strings, It's comparatively unlikely that you've been hacked.
If you're dealing with an odd string from your DNS server or if you want your prompt to always be consistent (and not depend on your local DNS server), you can use your login to set the PS1 variable to the string you want. This can be particularly useful for a MacBook Pro that is moving around among various networks, or where your local DNS is serving you an odd string.
You might choose to set your Terminal.app prompt to the local Mac host name from System Preferences.app and its Sharing display — not the DNS-determined reverse translation — using the bash PS1 environment variable. This host name is visible from the command line using either the scutil --get ComputerName command, or sometimes the networksetup -gethostname command. For example:
PS1="$(scutil --get ComputerName): Hello$ "
You can test the prompt string live, by just entering the command at the Terminal.app prompt.
Once you have a string you like, you can add it into your bash login.
From the bash documentation:
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists.When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
The order of execution is:
- /etc/profile
- The first of the following list of files, with only the first file located being invoked:
- ~/.bash_profile
- ~/.bash_login
- ~/.profile
The Linux documentation project offers an example of a login procedure
Bash itself provides various sequences for setting parts of the prompt string.
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May
26")
\D{format}
the format is passed to strftime(3) and the result is
inserted into the prompt string; an empty format results
in a locale-specific time representation. The braces are
required
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion
following the final slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patch level (e.g., 2.00.0)
\w the current working directory, with $HOME abbreviated
with a tilde
\W the basename of the current working directory, with $HOME
abbreviated with a tilde
\! the history number of this command
\# the command number of this command
\$ if the effective UID is 0, a #, otherwise a $
\nnn the character corresponding to the octal number nnn
\\ a backslash
\[ begin a sequence of non-printing characters, which could
be used to embed a terminal control sequence into the
prompt
\] end a sequence of non-printing characters
These tags are case-sensitive.
These tags can then be combined with your computer name, and lead you to using a prompt string such as:
PS1="$(scutil --get ComputerName):\W \u$ "
which shows your local computer name (and not the DNS server response), the interesting part of the current default directory (\W), and your login username shortname (\u) and then a dollar sign and a space.
With that \e tag for an escape character, you can provide a distinctly-colored PS1 variable.
The following is an example of setting all prompt text red using an escape sequence (control sequence). This PS1 example is from a line in a .bash_profile that turns the prompt red to warn that the prompt is on a production server.
PS1="\[\e[1;31m\]\u@\H $\[\e[0m\] "
There are various lists of escape sequences around for coloring the prompts, including the VT terminal documentation at vt100.net, and other sources including the ArchLinux wiki.

Comments
tput
Via VikingOSX and if your particular bash environment has it, the tput command is a handy way to fetch control strings directly from the terminal tables.
Any recent version of OS X has tput. For those using OpenVMS, GNV V3.0 lacks tput.
Gonzo login script description...
A graphical description of Unix startup (login) script processing, including bash, sh, and zsh login processing.
This is the analog of the OpenVMS login procedures including DECW$LOGIN, the moving-target gnv stuff, LOGIN.COM, SYLOGIN.COM and potentially a few other DCL procedures.