1.普通用户wenke 自动安装“oh my zsh”:

$su wenke

$cd 

$wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

$vi .oh-my-zsh/themes/robbyrussell.zsh-theme 

local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p%{$fg[cyan]%}%d %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}$'
#PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'

ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

保存退出.

(注意:此时不要新开终端,让修改生效!否则后面root身份自动安装zsh的时候,会提示/Users/wenke/.oh-my-zsh已存在)

 

 

2.把bash的配置文件导入zsh

 

$cat ~/.bash_profile >> ~/.zshrc

 

3.同一个终端里,切换到root,自动安装“oh my zsh”:

 

$su

#cd

#wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

#vi .oh-my-zsh/themes/robbyrussell.zsh-theme 

local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p%{$fg[cyan]%}%d %{$fg_bold[blue]%}$(git_pr    ompt_info)%{$fg_bold[blue]%}% %{$reset_color%}$'
#PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt    _info)%{$fg_bold[blue]%} % %{$reset_color%}'

ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

保存退出,新开终端,让之前两次修改同时生效!

 

 

4.效果如下:

wenke用户是红色箭头,$提示符

root 用户是绿色箭头,#提示符

 

 

5. 每次打开新窗口,都保持旧目录

Performance -> Profiles -> General -> Working Directory -> Reuse previous session's directory

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐