diff --git a/liquid.ps1 b/liquid.ps1 index 5b7c478..27f50e8 100644 --- a/liquid.ps1 +++ b/liquid.ps1 @@ -34,7 +34,7 @@ then # path in foreground color LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" # 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 # path in yellow LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" diff --git a/liquid.theme b/liquid.theme index 205ecef..744cc8b 100644 --- a/liquid.theme +++ b/liquid.theme @@ -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_SVN="‡" # prompt mark in svn 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 else # If charset is anything else, fallback to ASCII chars @@ -27,6 +28,7 @@ else LP_MARK_HG="m" LP_MARK_SVN="=" LP_MARK_GIT="+" + LP_MARK_FOSSIL="f" LP_MARK_UNTRACKED="*" fi diff --git a/liquidprompt b/liquidprompt index e5a1c2e..97ac754 100755 --- a/liquidprompt +++ b/liquidprompt @@ -199,10 +199,9 @@ _lp_source_config() LP_ENABLE_BATT=${LP_ENABLE_BATT:-1} LP_ENABLE_GIT=${LP_ENABLE_GIT:-1} LP_ENABLE_SVN=${LP_ENABLE_SVN:-1} + LP_ENABLE_FOSSIL=${LP_ENABLE_FOSSIL:-1} LP_ENABLE_HG=${LP_ENABLE_HG:-1} 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_ADAPTER=${LP_MARK_ADAPTER:-"⏚"} @@ -211,6 +210,7 @@ _lp_source_config() LP_MARK_HG=${LP_MARK_HG:-"☿"} LP_MARK_SVN=${LP_MARK_SVN:-"‡"} LP_MARK_GIT=${LP_MARK_GIT:-"±"} + LP_MARK_FOSSIL=${LP_MARK_FOSSIL:-"⌘"} LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"} LP_COLOR_PATH=${LP_COLOR_PATH:-$BOLD_WHITE} @@ -283,6 +283,7 @@ unset _lp_source_config # Disable features if the tool is not installed [[ "$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_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_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 # ################## @@ -933,6 +970,8 @@ _lp_smart_mark() mark=$LP_MARK_HG elif [[ ! -z $(_lp_svn_branch) ]] ; then mark=$LP_MARK_SVN + elif [[ ! -z $(_lp_fossil_branch) ]] ; then + mark=$LP_MARK_FOSSIL fi echo -ne "${COL}${mark}${NO_COL}" } @@ -1006,6 +1045,7 @@ _lp_set_prompt() LP_GIT=$(_lp_sl "$(_lp_git_branch_color)") LP_HG=$(_lp_sl "$(_lp_hg_branch_color)") LP_SVN=$(_lp_sl "$(_lp_svn_branch_color)") + LP_FOSSIL=$(_lp_sl "$(_lp_fossil_branch_color)") fi # end of the prompt line: double spaces @@ -1030,13 +1070,13 @@ _lp_set_prompt() # path in foreground color PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" # add VCS infos - PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}" + PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}" else # path in yellow PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}" # do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT) [[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && \ - PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}" + PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}" fi # add return code and prompt mark PS1="${PS1}${LP_ERR}${LP_MARK}"