2015-05-28 16:25:49 +02:00
|
|
|
# Michele Bologna's theme
|
2018-08-07 20:42:02 +02:00
|
|
|
# https://www.michelebologna.net
|
2015-05-28 16:25:49 +02:00
|
|
|
#
|
|
|
|
# This a theme for oh-my-zsh. Features a colored prompt with:
|
2018-08-07 20:42:02 +02:00
|
|
|
# * username@host: [jobs] [git] workdir %
|
|
|
|
# * hostname color is based on hostname characters. When using as root, the
|
2015-05-28 16:25:49 +02:00
|
|
|
# prompt shows only the hostname in red color.
|
|
|
|
# * [jobs], if applicable, counts the number of suspended jobs tty
|
|
|
|
# * [git], if applicable, represents the status of your git repo (more on that
|
|
|
|
# later)
|
|
|
|
# * '%' prompt will be green if last command return value is 0, yellow otherwise.
|
2018-08-07 20:42:02 +02:00
|
|
|
#
|
|
|
|
# git prompt is inspired by official git contrib prompt:
|
2015-05-28 16:25:49 +02:00
|
|
|
# https://github.com/git/git/tree/master/contrib/completion/git-prompt.sh
|
|
|
|
# and it adds:
|
|
|
|
# * the current branch
|
|
|
|
# * '%' if there are untracked files
|
|
|
|
# * '$' if there are stashed changes
|
|
|
|
# * '*' if there are modified files
|
|
|
|
# * '+' if there are added files
|
|
|
|
# * '<' if local repo is behind remote repo
|
|
|
|
# * '>' if local repo is ahead remote repo
|
|
|
|
# * '=' if local repo is equal to remote repo (in sync)
|
|
|
|
# * '<>' if local repo is diverged
|
|
|
|
|
|
|
|
local green="%{$fg_bold[green]%}"
|
|
|
|
local red="%{$fg_bold[red]%}"
|
|
|
|
local cyan="%{$fg_bold[cyan]%}"
|
|
|
|
local yellow="%{$fg_bold[yellow]%}"
|
|
|
|
local blue="%{$fg_bold[blue]%}"
|
|
|
|
local magenta="%{$fg_bold[magenta]%}"
|
|
|
|
local reset="%{$reset_color%}"
|
|
|
|
|
|
|
|
local -a color_array
|
2023-07-23 19:44:30 +02:00
|
|
|
color_array=($green $red $cyan $yellow $blue $magenta)
|
2015-05-28 16:25:49 +02:00
|
|
|
|
2023-07-23 19:44:30 +02:00
|
|
|
local username_color=$blue
|
|
|
|
local hostname_color=$color_array[$[((#HOST))%6+1]] # choose hostname color based on first character
|
2015-05-28 16:25:49 +02:00
|
|
|
local current_dir_color=$blue
|
2022-02-23 19:55:33 +01:00
|
|
|
|
|
|
|
local username="%n"
|
|
|
|
local hostname="%m"
|
2015-05-28 16:25:49 +02:00
|
|
|
local current_dir="%~"
|
|
|
|
|
2022-02-23 19:55:33 +01:00
|
|
|
local username_output="%(!..${username_color}${username}${reset}@)"
|
|
|
|
local hostname_output="${hostname_color}${hostname}${reset}"
|
|
|
|
local current_dir_output="${current_dir_color}${current_dir}${reset}"
|
2015-05-28 16:25:49 +02:00
|
|
|
local jobs_bg="${red}fg: %j$reset"
|
|
|
|
local last_command_output="%(?.%(!.$red.$green).$yellow)"
|
|
|
|
|
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX=""
|
2013-03-05 22:50:27 +01:00
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
2015-05-28 16:25:49 +02:00
|
|
|
ZSH_THEME_GIT_PROMPT_DIRTY=""
|
|
|
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
2015-06-16 10:48:24 +02:00
|
|
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="$blue%%"
|
|
|
|
ZSH_THEME_GIT_PROMPT_MODIFIED="$red*"
|
|
|
|
ZSH_THEME_GIT_PROMPT_ADDED="$green+"
|
|
|
|
ZSH_THEME_GIT_PROMPT_STASHED="$blue$"
|
|
|
|
ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="$green="
|
2015-05-28 16:25:49 +02:00
|
|
|
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
|
|
|
|
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
|
2015-06-16 10:48:24 +02:00
|
|
|
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="$red<>"
|
2013-03-05 22:50:27 +01:00
|
|
|
|
2022-02-23 19:55:33 +01:00
|
|
|
function michelebologna_git_prompt {
|
|
|
|
local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
|
|
|
|
[[ -n $out ]] || return
|
|
|
|
printf " %s(%s%s%s)%s" \
|
2023-07-23 19:44:30 +02:00
|
|
|
"%{$fg_bold[blue]%}" \
|
2022-02-23 19:55:33 +01:00
|
|
|
"%{$fg_bold[green]%}" \
|
|
|
|
"$out" \
|
2023-07-23 19:44:30 +02:00
|
|
|
"%{$fg_bold[blue]%}" \
|
2022-02-23 19:55:33 +01:00
|
|
|
"%{$reset_color%}"
|
|
|
|
}
|
|
|
|
|
|
|
|
PROMPT="$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)"
|
|
|
|
PROMPT+='$(michelebologna_git_prompt)'
|
2015-05-28 16:25:49 +02:00
|
|
|
PROMPT+=" $last_command_output%#$reset "
|
|
|
|
RPROMPT=''
|