Skip to content

Instantly share code, notes, and snippets.

@apaatsio
Created February 11, 2022 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apaatsio/4e5ad3f8969a36e5e0b9c6f364f81507 to your computer and use it in GitHub Desktop.
Save apaatsio/4e5ad3f8969a36e5e0b9c6f364f81507 to your computer and use it in GitHub Desktop.
Custom oh-my-zsh theme based on gnzh
setopt prompt_subst
() {
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
# Check the UID
if [[ $UID -ne 0 ]]; then # normal user
PR_USER='%F{green}%n%f'
PR_USER_OP='%F{green}%#%f'
PR_PROMPT='%f%(?..%F{red})➤ %f%{$reset_color%}'
else # root
PR_USER='%F{red}%n%f'
PR_USER_OP='%F{red}%#%f'
PR_PROMPT='%F{red}(root)➤ %f'
fi
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{red}%M%f' # SSH
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
else
local user_host=""
fi
local return_code="%(?..%{$fg_bold[red]%}%? ↵)"
local current_dir="%B%F{blue}%~%f%b"
local git_branch='$(git_prompt_info) $(git_prompt_status) $(git_remote_status)'
local current_time='${FG[237]}%*%{$reset_color%}'
PROMPT="%(?..%F{red})╭─${user_host} ${current_dir} ${git_branch}
%(?..%F{red})╰─$PR_PROMPT"
RPROMPT="${return_code} ${current_time}"
local git_suffix="%F{yellow}|$(git_prompt_short_sha)›%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="$git_suffix%{$fg_bold[red]%}×"
ZSH_THEME_GIT_PROMPT_CLEAN="$git_suffix%{$fg_bold[green]%}✓"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[green]%}+ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}M %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg_bold[red]%}- %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[blue]%}R %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[cyan]%}U %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}N %{$reset_color%}"
# ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="${FG[237]}equal%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE="${FG[032]}ahead%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="${FG[001]}behind%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="${FG[005]}diverged%{$reset_color%}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment