I don't know what this is called, can anyone clarify? Is it called the name / hostname. I don't know what you call it.

On Ubuntu my Terminal shows kalima@coolbox:~$

But on OSX my Terminal shows compname:~ kalima$

Is this normal? Is there a way to change it so they're both consistent in format?

2 Answers 2


That's called your "prompt". You can define the PS1 variable to control it.

Add the following to your ~/.bashrc file:

PS1='\u@\h:\w\$ '

See the bash manual for more details.

  • I don't have a .bashrc file, I have .bash_history, .bash_profile, and .bash_sessions
    – KaliMa
    Jul 24, 2017 at 17:56
  • Go ahead a create it as a new file. Add this to your .bash_profile: [[ -f ~/.bashrc ]] && source ~/.bashrc Jul 24, 2017 at 17:58
  • What does that do? And is there any reason why I didn't have the file to begin with? Will there be some weird side effect somewhere else?
    – KaliMa
    Jul 24, 2017 at 18:03
  • bash's dot files can get a bit complicated. A bash session can be a login or a non-login shell (that depends on your terminal's options), and it can be interactive or non-interactive (running a shell script is an example of non-interactive). Different combinations of those attributes affect which dot files are processed. See the manual for more. Typically, terminals launch a login shell, so we start with the .bash_profile. That doesn't by default read the .bashrc, so if that file exists, source it. Jul 24, 2017 at 20:27

You can also edit your ~/.bash_profile if you like having everything in one file.

For example, I have customized my terminal by adding this to my ~/.bash_profile.

    [[ -s ~/.bashrc ]] && source ~/.bashrc

    export CLICOLOR=1
    export LSCOLORS=GxFxCxDxBxegedabagaced
function prompt {
  local BLACK="\[\033[0;30m\]"
  local BLACKBOLD="\[\033[1;30m\]"
  local RED="\[\033[0;31m\]"
  local REDBOLD="\[\033[1;31m\]"
  local GREEN="\[\033[0;32m\]"
  local GREENBOLD="\[\033[1;32m\]"
  local YELLOW="\[\033[0;33m\]"
  local YELLOWBOLD="\[\033[1;33m\]"
  local BLUE="\[\033[0;34m\]"
  local BLUEBOLD="\[\033[1;34m\]"
  local PURPLE="\[\033[0;35m\]"
  local PURPLEBOLD="\[\033[1;35m\]"
  local CYAN="\[\033[0;36m\]"
  local CYANBOLD="\[\033[1;36m\]"
  local WHITE="\[\033[0;37m\]"
  local WHITEBOLD="\[\033[1;37m\]"
  local RESETCOLOR="\[\e[00m\]"

  export PS1="\n$RED\u $PURPLE@ $GREEN\w $RESETCOLOR$GREENBOLD\$(git branch 2> /dev/null)\n $BLUE[\#] → $RESETCOLOR"
  export PS2=" | → $RESETCOLOR"

Mine looks something like this: enter image description here

  • PS1 and PS2 are shell-specific variables. They don't need to be exported, unless you have other programs that use them. Jul 24, 2017 at 20:15
  • @glenn jackman Most JetBrains products have a terminal option, and the export allows me to use them there as well. Jul 24, 2017 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .