Changing username, hostname, and path color in iterm2

有些话、适合烂在心里 提交于 2020-06-01 05:05:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!