mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Modified lib/zsh.sh for better prefix/suffix support
This commit is contained in:
parent
d165a84dc0
commit
b643d50f5f
2 changed files with 9 additions and 6 deletions
13
lib/git.zsh
13
lib/git.zsh
|
|
@ -1,7 +1,12 @@
|
||||||
# get the name of the branch we are on
|
# get the name of the branch we are on
|
||||||
function git_prompt_info() {
|
function git_prompt_info() {
|
||||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
if parse_git_dirty; then
|
||||||
|
INFO="$ZSH_THEME_GIT_PROMPT_DIRTY_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||||
|
else
|
||||||
|
INFO="$ZSH_THEME_GIT_PROMPT_CLEAN_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||||
|
fi
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_PREFIX$INFO$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,11 +16,7 @@ parse_git_dirty() {
|
||||||
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||||
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
||||||
fi
|
fi
|
||||||
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
|
[[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]] && return 0 || return 1
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
|
||||||
else
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ PS1="%n@%m:%~%# "
|
||||||
# git theming default: Variables for theming the git info prompt
|
# git theming default: Variables for theming the git info prompt
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
|
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
||||||
|
ZSH_THEME_GIT_PROMPT_DIRTY_PREFIX="" # Text to display if the branch is dirty
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN_PREFIX="" # Text to display if the branch is clean
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||||
|
|
||||||
# Setup the prompt with pretty colors
|
# Setup the prompt with pretty colors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue