问题
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:
In iTerm2:
Current iTerm2 settings:
and
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
回答1:
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
回答2:
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
回答3:
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'
来源:https://stackoverflow.com/questions/62029637/changing-username-hostname-and-path-color-in-iterm2