Changing username, hostname, and path color in iterm2
Asked Answered
B

5

5

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

Brythonic answered 26/5, 2020 at 19:13 Comment(0)
B
9

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%}%%'
Brythonic answered 27/5, 2020 at 1:26 Comment(0)
N
3

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

Nub answered 2/6, 2020 at 17:34 Comment(0)
T
2

For Zsh Users enter image description here

As per this detailed discussion on formatting/coloring your prompt:

To color your hostname and username red, and the directory path yellow like in the image above, add the following to your ~/.zshrc :

# Load colors
autoload -U colors && colors
# Format your prompt using the colors
export PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[red]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "

Supported Colors as per this discussion are :
red, blue, green, cyan, yellow, magenta, black, & white

Twana answered 3/1, 2023 at 5:25 Comment(0)
G
0

I think you need to change the colors on your terminal prompt to achieve that, this may be of help http://www.marinamele.com/2014/05/customize-colors-of-your-terminal-in-mac-os-x.html

Geographer answered 26/5, 2020 at 20:31 Comment(1)
The article shows PS1 profile for bash, and the values and formatting are different in zshBrythonic
Z
0

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

Zoara answered 26/5, 2020 at 20:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.