mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-17 03:10:09 +00:00
refactor(michelebologna): simplify and clean up code
This commit is contained in:
parent
201e9dea59
commit
28dc8c58ef
1 changed files with 21 additions and 17 deletions
|
@ -35,23 +35,17 @@ local reset="%{$reset_color%}"
|
|||
local -a color_array
|
||||
color_array=($green $red $cyan $yellow $blue $magenta $white)
|
||||
|
||||
local username_normal_color=$white
|
||||
local username_root_color=$red
|
||||
local hostname_root_color=$red
|
||||
|
||||
# calculating hostname color with hostname characters
|
||||
for i in $HOST; local hostname_normal_color=$color_array[$[((#i))%7+1]]
|
||||
local -a hostname_color
|
||||
hostname_color=%(!.$hostname_root_color.$hostname_normal_color)
|
||||
|
||||
local username_color=$white
|
||||
local hostname_color=$color_array[$[((#HOST))%7+1]] # choose hostname color based on first character
|
||||
local current_dir_color=$blue
|
||||
local username_command="%n"
|
||||
local hostname_command="%m"
|
||||
|
||||
local username="%n"
|
||||
local hostname="%m"
|
||||
local current_dir="%~"
|
||||
|
||||
local username_output="%(!..$username_normal_color$username_command$reset@)"
|
||||
local hostname_output="$hostname_color$hostname_command$reset"
|
||||
local current_dir_output="$current_dir_color$current_dir$reset"
|
||||
local username_output="%(!..${username_color}${username}${reset}@)"
|
||||
local hostname_output="${hostname_color}${hostname}${reset}"
|
||||
local current_dir_output="${current_dir_color}${current_dir}${reset}"
|
||||
local jobs_bg="${red}fg: %j$reset"
|
||||
local last_command_output="%(?.%(!.$red.$green).$yellow)"
|
||||
|
||||
|
@ -68,8 +62,18 @@ ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
|
|||
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
|
||||
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="$red<>"
|
||||
|
||||
PROMPT='$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)'
|
||||
GIT_PROMPT='$(out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status);if [[ -n $out ]]; then printf %s " $white($green$out$white)$reset";fi)'
|
||||
PROMPT+="$GIT_PROMPT"
|
||||
function michelebologna_git_prompt {
|
||||
local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
|
||||
[[ -n $out ]] || return
|
||||
printf " %s(%s%s%s)%s" \
|
||||
"%{$fg_bold[white]%}" \
|
||||
"%{$fg_bold[green]%}" \
|
||||
"$out" \
|
||||
"%{$fg_bold[white]%}" \
|
||||
"%{$reset_color%}"
|
||||
}
|
||||
|
||||
PROMPT="$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)"
|
||||
PROMPT+='$(michelebologna_git_prompt)'
|
||||
PROMPT+=" $last_command_output%#$reset "
|
||||
RPROMPT=''
|
||||
|
|
Loading…
Reference in a new issue