Add support for fossil scm

Conflicts:
	liquidprompt
This commit is contained in:
Étienne Deparis 2012-12-29 02:42:29 +01:00
parent 947781bac9
commit a1891ddf5d
3 changed files with 47 additions and 5 deletions

View File

@ -34,7 +34,7 @@ then
# path in foreground color # path in foreground color
LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
# add VCS infos # add VCS infos
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}" LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
else else
# path in yellow # path in yellow
LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"

View File

@ -17,6 +17,7 @@ if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]
LP_MARK_HG="☿" # prompt mark in hg repositories LP_MARK_HG="☿" # prompt mark in hg repositories
LP_MARK_SVN="‡" # prompt mark in svn repositories LP_MARK_SVN="‡" # prompt mark in svn repositories
LP_MARK_GIT="±" # prompt mark in git repositories LP_MARK_GIT="±" # prompt mark in git repositories
LP_MARK_FOSSIL="⌘" # prompt mark in fossil repositories
LP_MARK_UNTRACKED="*" # if git has untracked files LP_MARK_UNTRACKED="*" # if git has untracked files
else else
# If charset is anything else, fallback to ASCII chars # If charset is anything else, fallback to ASCII chars
@ -27,6 +28,7 @@ else
LP_MARK_HG="m" LP_MARK_HG="m"
LP_MARK_SVN="=" LP_MARK_SVN="="
LP_MARK_GIT="+" LP_MARK_GIT="+"
LP_MARK_FOSSIL="f"
LP_MARK_UNTRACKED="*" LP_MARK_UNTRACKED="*"
fi fi

View File

@ -199,10 +199,9 @@ _lp_source_config()
LP_ENABLE_BATT=${LP_ENABLE_BATT:-1} LP_ENABLE_BATT=${LP_ENABLE_BATT:-1}
LP_ENABLE_GIT=${LP_ENABLE_GIT:-1} LP_ENABLE_GIT=${LP_ENABLE_GIT:-1}
LP_ENABLE_SVN=${LP_ENABLE_SVN:-1} LP_ENABLE_SVN=${LP_ENABLE_SVN:-1}
LP_ENABLE_FOSSIL=${LP_ENABLE_FOSSIL:-1}
LP_ENABLE_HG=${LP_ENABLE_HG:-1} LP_ENABLE_HG=${LP_ENABLE_HG:-1}
LP_ENABLE_TIME=${LP_ENABLE_TIME:-0} LP_ENABLE_TIME=${LP_ENABLE_TIME:-0}
LP_ENABLE_VIRTUALENV=${LP_ENABLE_VIRTUALENV:-1}
LP_ENABLE_VCS_ROOT=${LP_ENABLE_VCS_ROOT:-0}
LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"} LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"}
LP_MARK_ADAPTER=${LP_MARK_ADAPTER:-"⏚"} LP_MARK_ADAPTER=${LP_MARK_ADAPTER:-"⏚"}
@ -211,6 +210,7 @@ _lp_source_config()
LP_MARK_HG=${LP_MARK_HG:-"☿"} LP_MARK_HG=${LP_MARK_HG:-"☿"}
LP_MARK_SVN=${LP_MARK_SVN:-"‡"} LP_MARK_SVN=${LP_MARK_SVN:-"‡"}
LP_MARK_GIT=${LP_MARK_GIT:-"±"} LP_MARK_GIT=${LP_MARK_GIT:-"±"}
LP_MARK_FOSSIL=${LP_MARK_FOSSIL:-"⌘"}
LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"} LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"}
LP_COLOR_PATH=${LP_COLOR_PATH:-$BOLD_WHITE} LP_COLOR_PATH=${LP_COLOR_PATH:-$BOLD_WHITE}
@ -283,6 +283,7 @@ unset _lp_source_config
# Disable features if the tool is not installed # Disable features if the tool is not installed
[[ "$LP_ENABLE_GIT" = 1 ]] && { command -v git >/dev/null || LP_ENABLE_GIT=0 ; } [[ "$LP_ENABLE_GIT" = 1 ]] && { command -v git >/dev/null || LP_ENABLE_GIT=0 ; }
[[ "$LP_ENABLE_SVN" = 1 ]] && { command -v svn >/dev/null || LP_ENABLE_SVN=0 ; } [[ "$LP_ENABLE_SVN" = 1 ]] && { command -v svn >/dev/null || LP_ENABLE_SVN=0 ; }
[[ "$LP_ENABLE_FOSSIL" = 1 ]] && { command -v fossil >/dev/null || LP_ENABLE_FOSSIL=0 ; }
[[ "$LP_ENABLE_HG" = 1 ]] && { command -v hg >/dev/null || LP_ENABLE_HG=0 ; } [[ "$LP_ENABLE_HG" = 1 ]] && { command -v hg >/dev/null || LP_ENABLE_HG=0 ; }
[[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; } [[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; }
@ -731,6 +732,42 @@ _lp_svn_branch_color()
} }
# FOSSIL #
# Get the tag name of the current directory
_lp_fossil_branch()
{
[[ "$LP_ENABLE_FOSSIL" != 1 ]] && return
local branch
branch="$(fossil status 2>/dev/null | grep tags: | cut -c17-)"
[[ $? -eq 0 ]] && echo "$branch"
}
# Set a color depending on the branch state:
# - green if the repository is clean
# - red if there is changes to commit
# - TODO: yellow if there is some commits not pushed
_lp_fossil_branch_color()
{
[[ "$LP_ENABLE_FOSSIL" != 1 ]] && return
local branch
local ret
branch=$(_lp_fossil_branch)
if [[ ! -z "$branch" ]] ; then
local lines
lines=$(fossil changes | wc -l)
if [[ "$lines" -eq 0 ]] ; then
ret="${LP_COLOR_UP}${branch}${NO_COL}"
else
ret="${LP_COLOR_CHANGES}${branch}($lines)${NO_COL}" # changes to commit
fi
echo -ne "$ret"
fi
}
################## ##################
# Battery status # # Battery status #
################## ##################
@ -933,6 +970,8 @@ _lp_smart_mark()
mark=$LP_MARK_HG mark=$LP_MARK_HG
elif [[ ! -z $(_lp_svn_branch) ]] ; then elif [[ ! -z $(_lp_svn_branch) ]] ; then
mark=$LP_MARK_SVN mark=$LP_MARK_SVN
elif [[ ! -z $(_lp_fossil_branch) ]] ; then
mark=$LP_MARK_FOSSIL
fi fi
echo -ne "${COL}${mark}${NO_COL}" echo -ne "${COL}${mark}${NO_COL}"
} }
@ -1006,6 +1045,7 @@ _lp_set_prompt()
LP_GIT=$(_lp_sl "$(_lp_git_branch_color)") LP_GIT=$(_lp_sl "$(_lp_git_branch_color)")
LP_HG=$(_lp_sl "$(_lp_hg_branch_color)") LP_HG=$(_lp_sl "$(_lp_hg_branch_color)")
LP_SVN=$(_lp_sl "$(_lp_svn_branch_color)") LP_SVN=$(_lp_sl "$(_lp_svn_branch_color)")
LP_FOSSIL=$(_lp_sl "$(_lp_fossil_branch_color)")
fi fi
# end of the prompt line: double spaces # end of the prompt line: double spaces
@ -1030,13 +1070,13 @@ _lp_set_prompt()
# path in foreground color # path in foreground color
PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
# add VCS infos # add VCS infos
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}" PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
else else
# path in yellow # path in yellow
PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
# do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT) # do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT)
[[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && \ [[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && \
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}" PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
fi fi
# add return code and prompt mark # add return code and prompt mark
PS1="${PS1}${LP_ERR}${LP_MARK}" PS1="${PS1}${LP_ERR}${LP_MARK}"