mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-23 22:30:07 +00:00
enabled showing number of stashes for themes
This commit is contained in:
parent
fd01fd66ce
commit
594ad21b32
2 changed files with 21 additions and 6 deletions
19
lib/git.zsh
19
lib/git.zsh
|
@ -19,7 +19,6 @@ function git_prompt_info() {
|
||||||
|
|
||||||
local ref
|
local ref
|
||||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
||||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
|
||||||
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
||||||
|| return 0
|
|| return 0
|
||||||
|
|
||||||
|
@ -36,6 +35,8 @@ function git_prompt_info() {
|
||||||
# Checks if working tree is dirty
|
# Checks if working tree is dirty
|
||||||
function parse_git_dirty() {
|
function parse_git_dirty() {
|
||||||
local STATUS
|
local STATUS
|
||||||
|
local STASH_STATUS
|
||||||
|
local STASH_VALID=false
|
||||||
local -a FLAGS
|
local -a FLAGS
|
||||||
FLAGS=('--porcelain')
|
FLAGS=('--porcelain')
|
||||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
||||||
|
@ -53,11 +54,23 @@ function parse_git_dirty() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
||||||
|
STASH_STATUS="$(git stash list | wc -l)"
|
||||||
|
fi
|
||||||
|
if [[ ! -z ${ZSH_THEME_GIT_PROMPT_STASH} && ! -z ${ZSH_THEME_GIT_PROMPT_STASH_DIRTY} && ! -z ${ZSH_THEME_GIT_RESET_COLOR} ]]; then
|
||||||
|
STASH_VALID=true
|
||||||
fi
|
fi
|
||||||
if [[ -n $STATUS ]]; then
|
if [[ -n $STATUS ]]; then
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
if [[ ! -z ${STASH_STATUS} && ${STASH_STATUS} != 0 && ${STASH_VALID} == true ]]; then
|
||||||
|
echo "${ZSH_THEME_GIT_PROMPT_STASH_DIRTY}${STASH_STATUS}${ZSH_THEME_GIT_RESET_COLOR}"
|
||||||
|
else
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
if [[ ! -z ${STASH_STATUS} && ${STASH_STATUS} != 0 && ${STASH_VALID} ]]; then
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_STASH${STASH_STATUS}${ZSH_THEME_GIT_RESET_COLOR}"
|
||||||
|
else
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,11 @@
|
||||||
# dashed separator size
|
# dashed separator size
|
||||||
function afmagic_dashes {
|
function afmagic_dashes {
|
||||||
# check either virtualenv or condaenv variables
|
# check either virtualenv or condaenv variables
|
||||||
local python_env_dir="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
|
local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
|
||||||
local python_env="${python_env_dir##*/}"
|
|
||||||
|
|
||||||
# if there is a python virtual environment and it is displayed in
|
# if there is a python virtual environment and it is displayed in
|
||||||
# the prompt, account for it when returning the number of dashes
|
# the prompt, account for it when returning the number of dashes
|
||||||
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
|
if [[ -n "$python_env" && "$PS1" = \(* ]]; then
|
||||||
echo $(( COLUMNS - ${#python_env} - 3 ))
|
echo $(( COLUMNS - ${#python_env} - 3 ))
|
||||||
else
|
else
|
||||||
echo $COLUMNS
|
echo $COLUMNS
|
||||||
|
@ -34,6 +33,9 @@ RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_STASH="${FG[214]}\$"
|
||||||
|
ZSH_THEME_GIT_RESET_COLOR="%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_STASH_DIRTY="${FG[214]}*\$"
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
||||||
|
|
||||||
# hg settings
|
# hg settings
|
||||||
|
|
Loading…
Reference in a new issue