themes: Adapt themes to new scm_prompt api

This commit is contained in:
Noah Gorny
2021-05-16 16:53:32 +03:00
parent 2ae0350f5d
commit dff892e0a3
14 changed files with 33 additions and 180 deletions

View File

@@ -28,17 +28,6 @@ else
THEME_PROMPT_HOST_COLOR="$blue"
fi
doubletime_scm_prompt() {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]; then
return
elif [ $CHAR = $SCM_GIT_CHAR ]; then
echo "$(git_prompt_status)"
else
echo "[$(scm_prompt_info)]"
fi
}
function prompt_setter() {
# Save history
history -a
@@ -46,27 +35,9 @@ function prompt_setter() {
history -r
PS1="
$(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
$(doubletime_scm_prompt)$reset_color $ "
$(scm_prompt)$reset_color $ "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
git_prompt_status() {
local git_status_output
git_status_output=$(git status 2> /dev/null )
if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then
git_status="${bold_red}$(scm_prompt_info)"
elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then
git_status="${bold_yellow}$(scm_prompt_info) ^"
elif [ -n "$(echo $git_status_output | grep 'Untracked files')" ]; then
git_status="${bold_cyan}$(scm_prompt_info) +"
elif [ -n "$(echo $git_status_output | grep 'nothing to commit')" ]; then
git_status="${bold_green}$(scm_prompt_info) ${green}"
else
git_status="$(scm_prompt_info)"
fi
echo "[$git_status${normal}]"
}