Changing username, hostname, and path color in iterm2

Viewed 6424

How can I change the username, hostname, and path color in iTerm2? I'm using the built-in Solarized colorscheme.

In Ubuntu, the same built-in colorscheme is highlighted like: enter image description here

In iTerm2: enter image description here

Current iTerm2 settings: enter image description here

and enter image description here

I've been playing around the settings but can't get it to work. I've also gone through numerous links, but those also settings don't work.

I'm on macOS 10.15.4

4 Answers

Default value of $PS1:

%n@%m %1~ %#

Updated value of $PS1 from this link (in the Prompt Example section):

%(?.%F{green}.%F{green})%n@%m %1~ %# %f

Added the below in my .zshrc:

export PS1='%(?.%F{green}.%F{green})%n@%m %1~ %# %f'

Edit:

The PS1 below provides more options:

export PS1='%{%F{green}%}%n%{%f%}%{%F{white}%}@%{%f%}%{%F{green}%}%m %{%F{cyan}%}%1~ %{%f%}%%'

This is what I am using now. Colours for prompt and ls command.

RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
PURPLE='\033[1;35m'
CYAN='\033[1;36m'
WHITE='\033[1;37m'
RESET='\033[0m'

export PS1="$RED\u:$BLUE\w $GREEN\h$RESET$ "
export CLICOLOR=1
export LSCOLORS=GxFxCxDxbxegedabagaced

Output: LSCOLORS and PS1

You should the PS1 environment variable in your bash / zsh profile file.

For example, if you're using bash, you could add the following line to ~/.bash_profile:

export PS1='\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ '

A more detailed explanation of this env variable can be found here

Related