站点更新:2018-11-14 10:39:39

This commit is contained in:
ehlxr 2018-11-14 10:39:39 +08:00
parent 0302c99abd
commit 0d7afef43d
3 changed files with 63 additions and 12 deletions

51
config/ehlxr.zsh-theme Normal file
View File

@ -0,0 +1,51 @@
# VCS
YS_VCS_PROMPT_PREFIX1="%{$fg[white]%}(%{$reset_color%}"
YS_VCS_PROMPT_PREFIX2="%{$fg[cyan]%}"
YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o"
YS_VCS_PROMPT_CLOSE="%{$fg[white]%}) %{$reset_color%}"
# Git info.
local git_info='$(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}${YS_VCS_PROMPT_PREFIX2}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
ZSH_THEME_GIT_PROMPT_DIRTY="${YS_VCS_PROMPT_DIRTY}${YS_VCS_PROMPT_CLOSE}"
ZSH_THEME_GIT_PROMPT_CLEAN="${YS_VCS_PROMPT_CLEAN}${YS_VCS_PROMPT_CLOSE}"
# root user
local root_symbols
[[ $UID -eq 0 ]] && root_symbols+=" %{%F{yellow}%}*"
# background jobs
local bg_symbols='$(prompt_background_jobs)'
prompt_background_jobs() {
local background_jobs_number=${$(jobs -l | wc -l)// /}
if [[ background_jobs_number -gt 0 ]]; then
echo " %{%F{cyan}%}&"
fi
}
local exit_code="%(?,, C:%{$fg[red]%}%?%{$reset_color%})"
# PROMPT="
# %{$terminfo[bold]$fg[blue]%}⌘%{$reset_color%} \
# %{$terminfo[bold]$fg[yellow]%}%~ %{$reset_color%}\
# ${git_info}\
# %{$fg[white]%}[%*]\
# ${root_symbols}${bg_symbols}\
# $exit_code
# %{%F{green}%}➜ %{$reset_color%}"
PROMPT="
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
%{$fg[cyan]%}%n \
%{$fg[white]%}in \
%{$terminfo[bold]$fg[yellow]%}%~ %{$reset_color%}\
${git_info}\
%{$fg[white]%}[%*]\
${root_symbols}${bg_symbols}\
%(?,%{$fg[green]%}, %{$fg[red]%})
➜ %{$reset_color%}"

View File

@ -1,4 +1,4 @@
# Based on bira theme
# Based on gnzh theme
setopt prompt_subst
@ -10,24 +10,24 @@ local PR_USER PR_USER_OP PR_PROMPT PR_HOST
if [[ $UID -ne 0 ]]; then # normal user
PR_USER='%F{green}%n%f'
PR_USER_OP='%F{green}%#%f'
PR_PROMPT='%f> %f'
else # root
PR_USER='%F{yellow}%n%f'
PR_USER_OP='%F{yellow}%#%f'
PR_PROMPT='%f> %f'
PR_USER='%F{red}%n%f'
PR_USER_OP='%F{red}%#%f'
fi
# PR_PROMPT='%f> %f'
PR_PROMPT='%(?,%{$fg[green]%},%{$fg[red]%})> %{$reset_color%}'
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{red}%M%f' # SSH
PR_HOST='%F{yellow}%M%f' # SSH
else
PR_HOST='%F{green}%M%f' # no SSH
PR_HOST='%F{cyan}%M%f' # no SSH
fi
local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local user_host="${PR_USER}%F{white}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
local rvm_ruby=''
if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
@ -40,9 +40,9 @@ fi
local git_branch='$(git_prompt_info)'
PROMPT="╭─${user_host} ${current_dir} [%*] ${git_branch} ${rvm_ruby}
╰─$PR_PROMPT"
RPROMPT="${return_code}"
PROMPT="%F{white}╭─ ${user_host} ${current_dir} ${git_branch} ${rvm_ruby}
%F{white}╰─$PR_PROMPT"
RPROMPT="${return_code} [%D{%H:%M:%S}]"
ZSH_THEME_GIT_PROMPT_PREFIX="%F{green}("
#ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}"

View File

@ -28,7 +28,7 @@ git clone https://github.com/zsh-users/zsh-history-substring-search.git /root/.o
echo -e "\033[1;33mConfig oh-my-zsh...\033[0m"
cp -f /vagrant/config/zshrc ~/.zshrc
cp -f /vagrant/config/my.zsh ~/.oh-my-zsh/custom/
cp -f /vagrant/config/gnzh.zsh-theme ~/.oh-my-zsh/themes/
cp -f /vagrant/config/ehlxr2.zsh-theme ~/.oh-my-zsh/custom/themes/
echo -e "\033[1;33mConfig ssh...\033[0m"
mkdir -p ~/.ssh && cat /vagrant/config/authorized.key >> ~/.ssh/authorized_keys