What is the "host name" in bash? (\h or \H) I set PS1="[\u@\H \w] in bash. So it should print the host name. But I do not understand the meaning and nature of the host name.

Basically, I would assume that it is just a name I assigned to my computer. But depending on different WLANs I use (public/university/home), this seems to be a different name for my own Mac Book Pro.

How is this name set? Could I define a fixed host name for my Mac or is this not possible?
First, you need to set your system name in System Preferences > Sharing > Computer Name. Let's assume for now that you set it to MyComputerName.

The next step is to make sure your computer name is not overridden by DHCP client (which is normally what happens and what you have observed - each time a DHCP server assigns and IP address to your computer, your mac will use the hostname associated with that IP address as its own).

To do that, you need to, in Terminal.app change the content of the /etc/hostconfig file, adding something similar to this: 

HOSTNAME="MyComputerName"


where MyComputerName is a text string corresponds to the host name you set in System Preferences. 

If you ever need to set it to change the hostname automatically based on the address received from the DHCP server, you can either remove this line from the /etc/hostconfig file or change it's value to -AUTOMATIC- instead of the "MyComputerName". 

Finally, in bash you use \h as the host name token - so e.g. you can set your PS1 to:

PS1='[\u@\h \w] '