Skip to content

Instantly share code, notes, and snippets.

@MrShennawy
Last active May 28, 2023 10:18
Show Gist options
  • Save MrShennawy/6f43bae5ed278858a7625483c76a7842 to your computer and use it in GitHub Desktop.
Save MrShennawy/6f43bae5ed278858a7625483c76a7842 to your computer and use it in GitHub Desktop.
# shellcheck disable=SC2168
# shellcheck disable=SC1087
# Shennawy's theme
#
# This a theme for oh-my-zsh. Features a colored prompt with:
# * ➜ workdir git:(git) $
# * '$' prompt will be green if last command return value is 0, red otherwise.
#
# git prompt is inspired by official git contrib prompt:
# https://github.com/git/git/tree/master/contrib/completion/git-prompt.sh
# and it adds:
# * the current branch
# * '*' if there are untracked files
# * 'S' 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 white="%{$fg_bold[white]%}"
local reset="%{$reset_color%}"
local last_command_output="%(?.%(!.$red.$green).$red)"
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_UNTRACKED=" $yellow*"
ZSH_THEME_GIT_PROMPT_MODIFIED=" $red!"
ZSH_THEME_GIT_PROMPT_ADDED=" $green+"
ZSH_THEME_GIT_PROMPT_STASHED=" %{$yellow%}S"
ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE=""
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE=" $red<>"
function shennawy_git_prompt {
local statusChangedColor=$white
if [[ $(git_prompt_status) ]]
then
local statusChangedColor=$red
fi
local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
[[ -n $out ]] || return
printf " %sgit:(%s%s%s)%s" \
"%{$fg_bold[blue]%}" \
"$statusChangedColor" \
"$out" \
"%{$fg_bold[blue]%}" \
"%{$reset_color%}"
}
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT+='%{$fg[cyan]%}%c%{$reset_color%}'
PROMPT+='$(shennawy_git_prompt) '
PROMPT+="$last_command_output%(!.#.$)$reset "
RPROMPT=''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment