I don't know how long ago this happened, but today I realized that when I open up terminal it no longer says


as it used to. Instead, it appears to have synched up with my roommate's macbook pro. It now displays:


I've restarted my mac but it doesn't change the name.

I've tried the suggestions suggested in these posts

sudo scutil --set HostName Matthew-Macbook

But no effect!

echo "$PS1" returns \h:\W \u\$


1 Answer 1


I know this is late, but the solution here may work for others with similar roommates.

I am thinking that your hostname is properly set, but that your prompt definition may have been pranked.

First check is to run 'echo $PROMPT && echo $PS1' and see if they match. If they don't, then we are looking for a prompt re-definition for sure but it is worthwhile to investigate fully anyways.

The terminal prompt is defined in several places and I suggest you look at them all for alterations

I am assuming that you use bash as your shell based on the output from your echo command. When I went to Mojave I switched to zsh, but I kept my bash settings. This following is from my previous master file.

# ==============

Last edited: 2019/07/08

Bash first reads and executes commands from the file /etc/profile, if that file exists. From that file it calls (appends) /private/etc/bashrc, the System-wide bashrc file for interactive bash(1) shells. That bashrc checks if bash is interactive, then sets windowsize parms, and then appends Apple terminal definitions before returning control to here

After reading those files, 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.

# ================

You should look at /private/etc/profile and /private/etc/bashrc as system wide prompts can be set there.

Also look at the ~/.bash_profile, ~/.bash_login, and ~/.profile files as they are the final place your prompt is set.

In general you are looking statements along the lines of: PS1=' some set of esc sequences like '\n and '\u mixed with the chars like '$' or '@''


PROMPT= the same as just above.

If you see Gabiel's name in any of those files then that is the one to change.

I would look at these files in reverse order.

If you are interested, putting the following would give you a nice terminal front based on a Green on Black Homebrew profile for you, root, and you as sudo -s. Of course you could modify it as you see fit as the colours are defined too. Copy following to the end of /private/etc/profile:

# declare ANSI color codes VARs

 RS="\[\033[0m\]"        # reset
 HC="\[\033[1m\]"        # hicolor
 UL="\[\033[4m\]"        # underline
 INV="\[\033[7m\]"       # inverse background and foreground
 FBLK="\[\033[30m\]"     # foreground black
 FRED="\[\033[31m\]"     # foreground red
 FGRN="\[\033[32m\]"     # foreground green
 FYEL="\[\033[33m\]"     # foreground yellow
 FBLE="\[\033[34m\]"     # foreground blue
 FMAG="\[\033[35m\]"     # foreground magenta
 FCYN="\[\033[36m\]"     # foreground cyan
 FWHT="\[\033[37m\]"     # foreground white
 BBLK="\[\033[40m\]"     # background black
 BRED="\[\033[41m\]"     # background red
 BGRN="\[\033[42m\]"     # background green
 BYEL="\[\033[43m\]"     # background yellow
 BBLE="\[\033[44m\]"     # background blue
 BMAG="\[\033[45m\]"     # background magenta
 BCYN="\[\033[46m\]"     # background cyan
 BWHT="\[\033[47m\]"     # background white
 BFRED="\[\033[01;31m\]" # bright foreground red
 BFGRN="\[\033[01;32m\]" # bright foreground green
 BFYEL="\[\033[01;33m\]" # bright foreground yellow
 BFBLE="\[\033[01;34m\]" # bright foreground blue
 BFMAG="\[\033[01;35m\]" # bright foreground magenta
 BFCYN="\[\033[01;36m\]" # bright foreground cyan
 BFWHT="\[\033[01;37m\]" # bright foreground white

# end colour VARs

# set colour prompt

    export SUDO_PS1='\n'$BFRED'\u'$BFGRN'@'$BFRED'\h'$BFGRN':'$BFBLE'\w '$RS''$FRED'$ '

    if [[ ${EUID} != 0 ]]; then
        export PS1='\n'$BFGRN'\u'$BFRED'@'$BFGRN'\h'$BFRED':'$BFBLE'\w '$RS''$FGRN'# '
        export PS1='\n'$BFRED'\u'$BFGRN'@'$BFRED'\h'$BFGRN':'$BFBLE'\w '$RS''$FRED'$ '

# end set prompt

You must log in to answer this question.

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