diff options
author | Marc Cornellà <hello@mcornella.com> | 2022-02-23 19:55:33 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2022-02-24 13:55:00 +0100 |
commit | 28dc8c58ef14325d94feb7f34616839c7975e7d0 (patch) | |
tree | 6ee410a7de5e8b3f54d4166268284c5dcbdda3cb /themes/michelebologna.zsh-theme | |
parent | 201e9dea594ea0a477370ae8dba6d09f9ae79149 (diff) | |
download | zsh-28dc8c58ef14325d94feb7f34616839c7975e7d0.tar.gz zsh-28dc8c58ef14325d94feb7f34616839c7975e7d0.tar.bz2 zsh-28dc8c58ef14325d94feb7f34616839c7975e7d0.zip |
refactor(michelebologna): simplify and clean up code
Diffstat (limited to 'themes/michelebologna.zsh-theme')
-rw-r--r-- | themes/michelebologna.zsh-theme | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/themes/michelebologna.zsh-theme b/themes/michelebologna.zsh-theme index bb567b3d8..bb86d68db 100644 --- a/themes/michelebologna.zsh-theme +++ b/themes/michelebologna.zsh-theme @@ -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='' |