Last active
March 7, 2018 10:42
-
-
Save trunneml/7462877 to your computer and use it in GitHub Desktop.
My ZSH-Theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U colors && colors | |
autoload -Uz vcs_info | |
autoload -U add-zsh-hook | |
setopt prompt_subst | |
VCS_PRE="%{$fg[red]%}[%{$reset_color%}" | |
VCS_SUF="%{$fg[red]%}]%{$reset_color%}" | |
AVCS_PRE="%{$fg_no_bold[green]%}{%{$reset_color%}" | |
AVCS_SUF="%{$fg_no_bold[green]%}}%{$reset_color%}" | |
VCS_PROMPT="%{$fg[magenta]%}[%r%{$fg[magenta]%}|%{$reset_color%}%{$fg_bold[yellow]%}%b %{$reset_color%}%u%c%{$fg_no_bold[magenta]%}]%{$reset_color%}%m %{$fg_no_bold[cyan]%}%S%{$reset_color%} " | |
AVCS_PROMPT="$VCS_PROMPT$AVCS_PRE%a$AVCS_SUF " | |
COLON="%{$fg[red]%}:%{$reset_color%}" | |
SPACE=" " | |
DELIM=$SPACE | |
UNTRACKED="%{$fg_bold[red]%}✎" | |
STAGED="%{$fg_bold[green]%}✐" | |
UNSTAGED="%{$fg_bold[yellow]%}✏" | |
zstyle ':vcs_info:*' check-for-changes true | |
zstyle ':vcs_info:*' stagedstr $STAGED | |
zstyle ':vcs_info:*' unstagedstr $UNSTAGED | |
zstyle ':vcs_info:*' formats $VCS_PROMPT | |
zstyle ':vcs_info:*' actionformats $AVCS_PROMPT | |
zstyle ':vcs_info:*' enable git | |
zstyle ':vcs_info:git*+set-message:*' hooks git-aheadbehind git-untracked git-message | |
### git: Show +N/-N when your local branch is ahead-of or behind remote HEAD. | |
# Make sure you have added misc to your 'formats': %m | |
function +vi-git-aheadbehind() { | |
local ahead behind | |
local -a gitstatus | |
# for git prior to 1.7 | |
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l) | |
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) | |
(( $ahead )) && gitstatus+=( "%{$fg_no_bold[blue]%}↥${ahead}%{$reset_color%}" ) | |
# for git prior to 1.7 | |
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l) | |
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) | |
(( $behind )) && gitstatus+=( "%{$fg_no_bold[red]%}↧${behind}%{$reset_color%}" ) | |
hook_com[misc]+=${(j::)gitstatus} | |
if [[ -n ${hook_com[misc]} ]]; then | |
hook_com[misc]="%{$fg_no_bold[magenta]%}[${hook_com[misc]}%{$fg_no_bold[magenta]%}]" | |
fi | |
} | |
### git: Show marker (T) if there are untracked files in repository | |
# Make sure you have added staged to your 'formats': %c | |
function +vi-git-untracked(){ | |
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ | |
git status --porcelain | grep '??' &> /dev/null ; then | |
# This will show the marker if there are any untracked files in repo. | |
# If instead you want to show the marker only if there are untracked | |
# files in $PWD, use: | |
#[[ -n $(git ls-files --others --exclude-standard) ]] ; then | |
if [[ -n ${hook_com[unstaged]} ]]; then | |
hook_com[unstaged]="$UNTRACKED$DELIM${hook_com[unstaged]}" | |
else | |
hook_com[unstaged]="$UNTRACKED" | |
fi | |
fi | |
} | |
# proper spacing | |
function +vi-git-message(){ | |
if [[ -n ${hook_com[unstaged]} ]]; then | |
if [[ -n ${hook_com[staged]} ]]; then | |
hook_com[unstaged]=" ${hook_com[unstaged]}$DELIM" | |
else | |
hook_com[unstaged]=" ${hook_com[unstaged]}" | |
fi | |
else | |
if [[ -n ${hook_com[staged]} ]]; then | |
hook_com[staged]=" ${hook_com[staged]}" | |
fi | |
fi | |
} | |
if [ -n "$SSH_CONNECTION" ]; then | |
HOST_PROMPT="%{$fg_bold[yellow]%}%m%{$fg_bold[white]%}:" | |
else | |
HOST_PROMPT="%{$fg[green]%}➜ " | |
fi | |
PROMPT_ENDING="%(#.%{$fg_bold[red]%}.%{$fg[white]%})%#%{$reset_color%}" | |
PS1='$PR_STITLE\ | |
%(?..%{$fg[red]%}[%?])\ | |
$HOST_PROMPT\ | |
%{$fg_no_bold[cyan]%}%~ \ | |
%(#.%{$fg_bold[red]%}.%{$fg[white]%})%#\ | |
$PROMPT_ENDING' | |
PS2="%_>" | |
RPS1='%(#.%{$fg_no_bold[red]%}.%{$fg_no_bold[green]%})%n\ | |
%{$fg_no_bold[white]%}@%{$fg_bold[white]%}%* %{$reset_color%}\ | |
$(virtualenv_prompt_info)%{$reset_color%}' | |
add-zsh-hook precmd prompt-precmd | |
prompt-precmd() { | |
vcs_info | |
if [[ -n ${vcs_info_msg_0_} ]]; then | |
PS1='$PR_STITLE\ | |
%(?..%{$fg[red]%}[%?])\ | |
${vcs_info_msg_0_}%{$reset_color%}$PROMPT_ENDING ' | |
else | |
PS1='$PR_STITLE\ | |
%(?..%{$fg[red]%}[%?])\ | |
$HOST_PROMPT\ | |
%{$fg_no_bold[cyan]%}%~ \ | |
$PROMPT_ENDING ' | |
fi | |
} | |
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment