Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change username color in Terminal on Mac

Tags:

terminal

macos

I've looked everywhere and can't find anything. How do I change the color of this whole line in the terminal?

user@MacBook-Pro ~ %

like image 811
user845978 Avatar asked Jan 01 '23 09:01

user845978


2 Answers

I tried all solutions above, but none of them work with new ZSH terminal on MacOS, so, I discover a new solution.

  1. open terminal e go to the user folder with: cd ~;
  2. create a new file called .zshrc with: touch .zshrc;
  3. open the file with VI: vi .zshrc;
  4. enter in the edit mode: press I key;
  5. paste the following code with CMD + V:
NEWLINE=$'\n'
DATE=$( date +"[%Y-%m-%d %H:%M:%S]" )
PROMPT="${NEWLINE}%F{yellow}${DATE} %(!.%F{red}.%F{white})%n%F{cyan}@%m %F{yellow}%d${NEWLINE}%F{reset}> "
  1. quit of edit: press ESC;
  2. save the changes and quit: press :wq;
  3. close Terminal app and open again, you should see something like this:

enter image description here

Source: https://askubuntu.com/a/549150/1127802

like image 147
Ângelo Polotto Avatar answered Jan 05 '23 17:01

Ângelo Polotto


You can use this generator for customize your PROMPT - https://zsh-prompt-generator.site/

  1. cd
  2. nano .zshrc
  3. Paste your PROMPT(example - PROMPT="%(!.%F{red}.%F{white})%n%F{cyan}@%m%F{yellow}%~$%F{reset}")
  4. Save changes and reload terminal.
like image 32
Mykhailo Matrosov Avatar answered Jan 05 '23 17:01

Mykhailo Matrosov