oh-my-zsh theme configuration
The default zsh
theme robbyrussell
has been great, simple and efficient, can be a good display git
of information, such as branch
information, 修改
, 删除
, 添加
and other operations, but the multi-user, then it can not be a good show, we can modify robbyrussell
to achieve the profile we want to effect.
Under normal circumstances, we install oh-my-zsh
are in their own home directory ~
, so we have to home directory, for example.
Edit ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
the file:
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
The local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
revised tolocal ret_status="%(?:%{$fg_bold[yellow]%}${USER} %{$fg_bold[green]%}➜ :%{$fg_bold[yellow]%}${USER} %{$fg_bold[red]%}➜ )"
as follows:
local ret_status="%(?:%{$fg_bold[yellow]%}${USER} %{$fg_bold[green]%}➜ :%{$fg_bold[yellow]%}${USER} %{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
When using this su
switching user name or the original, a determination is added:
if [ `id -u` -eq 0 ];then
local ret_status="%(?:%{$fg_bold[yellow]%}root %{$fg_bold[green]%}➜ :%{$fg_bold[yellow]%}root %{$fg_bold[red]%}➜ )"
else
local ret_status="%(?:%{$fg_bold[yellow]%}${USER} %{$fg_bold[green]%}➜ :%{$fg_bold[yellow]%}${USER} %{$fg_bold[red]%}➜ )"
fi
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
Save and exit, executed in the terminal source .zshrc
allows configuration to take effect.
Style is " root ➜ ~
."