Merge pull request #91 from milouse/develop
Add support for Fossil SCM (the return)
This commit is contained in:
commit
36659d81ee
19
README.md
19
README.md
@ -56,14 +56,15 @@ preserving the first two directories;
|
|||||||
* the current Python virtual environment, if any;
|
* the current Python virtual environment, if any;
|
||||||
* an up arrow if an HTTP proxy is in use;
|
* an up arrow if an HTTP proxy is in use;
|
||||||
* the name of the current branch if you are in a version control repository
|
* the name of the current branch if you are in a version control repository
|
||||||
(git, mercurial or subversion), in green if everything is up to date, in red if
|
(git, mercurial, subversion or fossil), in green if everything is up
|
||||||
there is changes, in yellow if there is pending commits to push;
|
to date, in red if there is changes, in yellow if there is pending
|
||||||
* the number of added/deleted lines, if changes have been made and the number
|
commits to push;
|
||||||
of pending commits, if any;
|
* the number of added/deleted lines (git) or files (fossil), if
|
||||||
|
changes have been made and the number of pending commits, if any;
|
||||||
* a star if there is some untracked files in the repository;
|
* a star if there is some untracked files in the repository;
|
||||||
* the error code of the last command, if it has failed in some way;
|
* the error code of the last command, if it has failed in some way;
|
||||||
* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, $ for simple
|
* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, ⌘
|
||||||
user, a red # for root.
|
for fossil, $ for simple user, a red # for root.
|
||||||
|
|
||||||
You can temporarily deactivate the liquid prompt and come back to your previous
|
You can temporarily deactivate the liquid prompt and come back to your previous
|
||||||
one by typing `prompt_off`. Use `prompt_on` to bring it back. You can deactivate
|
one by typing `prompt_off`. Use `prompt_on` to bring it back. You can deactivate
|
||||||
@ -124,6 +125,7 @@ building:
|
|||||||
* `LP_ENABLE_GIT`, if you want to have git informations
|
* `LP_ENABLE_GIT`, if you want to have git informations
|
||||||
* `LP_ENABLE_SVN`, if you want to have subversion informations
|
* `LP_ENABLE_SVN`, if you want to have subversion informations
|
||||||
* `LP_ENABLE_HG`, if you want to have mercurial informations
|
* `LP_ENABLE_HG`, if you want to have mercurial informations
|
||||||
|
* `LP_ENABLE_FOSSIL`, if you want to have fossil informations
|
||||||
* `LP_ENABLE_VCS_ROOT`, if you want to show VCS informations with root account
|
* `LP_ENABLE_VCS_ROOT`, if you want to show VCS informations with root account
|
||||||
|
|
||||||
Note that if required commands are not installed, enabling the
|
Note that if required commands are not installed, enabling the
|
||||||
@ -162,6 +164,7 @@ Available features:
|
|||||||
* `LP_GIT` git
|
* `LP_GIT` git
|
||||||
* `LP_HG` mercurial
|
* `LP_HG` mercurial
|
||||||
* `LP_SVN` subversion
|
* `LP_SVN` subversion
|
||||||
|
* `LP_FOSSIL` fossil
|
||||||
* `LP_ERR` last error code
|
* `LP_ERR` last error code
|
||||||
* `LP_MARK` prompt mark
|
* `LP_MARK` prompt mark
|
||||||
|
|
||||||
@ -223,7 +226,7 @@ Set to a null string "" if you do not want color.
|
|||||||
* `LP_COLOR_UP` repository is up to date / a push have been made
|
* `LP_COLOR_UP` repository is up to date / a push have been made
|
||||||
* `LP_COLOR_COMMITS` some commits have not been pushed
|
* `LP_COLOR_COMMITS` some commits have not been pushed
|
||||||
* `LP_COLOR_CHANGES` there is some changes to commit
|
* `LP_COLOR_CHANGES` there is some changes to commit
|
||||||
* `LP_COLOR_DIFF` number of lines impacted by current changes
|
* `LP_COLOR_DIFF` number of lines or files impacted by current changes
|
||||||
* Battery
|
* Battery
|
||||||
* `LP_COLOR_CHARGING_ABOVE` charging and above threshold
|
* `LP_COLOR_CHARGING_ABOVE` charging and above threshold
|
||||||
* `LP_COLOR_CHARGING_UNDER` charging but under threshold
|
* `LP_COLOR_CHARGING_UNDER` charging but under threshold
|
||||||
@ -241,6 +244,7 @@ Special characters:
|
|||||||
* `LP_MARK_HG` (default: "☿") prompt mark in hg repositories
|
* `LP_MARK_HG` (default: "☿") prompt mark in hg repositories
|
||||||
* `LP_MARK_SVN` (default: "‡") prompt mark in svn repositories
|
* `LP_MARK_SVN` (default: "‡") prompt mark in svn repositories
|
||||||
* `LP_MARK_GIT` (default: "±") prompt mark in git repositories
|
* `LP_MARK_GIT` (default: "±") prompt mark in git repositories
|
||||||
|
* `LP_MARK_FOSSIL` (default: "⌘") prompt mark in fossil repositories
|
||||||
* `LP_MARK_UNTRACKED` (default: "*") if git has untracked files
|
* `LP_MARK_UNTRACKED` (default: "*") if git has untracked files
|
||||||
|
|
||||||
|
|
||||||
@ -256,4 +260,3 @@ the display of the liquid prompt.
|
|||||||
* Subversion repository cannot display commits to be pushed, this is a
|
* Subversion repository cannot display commits to be pushed, this is a
|
||||||
limitation of the Subversion versionning model.
|
limitation of the Subversion versionning model.
|
||||||
* The proxy detection only uses the `$http_proxy` environment variable.
|
* The proxy detection only uses the `$http_proxy` environment variable.
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@ 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}"
|
||||||
# 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" ]] && \
|
||||||
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}"
|
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
|
||||||
fi
|
fi
|
||||||
# add return code and prompt mark
|
# add return code and prompt mark
|
||||||
LP_PS1="${LP_PS1}${LP_ERR}${LP_MARK}"
|
LP_PS1="${LP_PS1}${LP_ERR}${LP_MARK}"
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
94
liquidprompt
94
liquidprompt
@ -200,6 +200,7 @@ _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_VIRTUALENV=${LP_ENABLE_VIRTUALENV:-1}
|
||||||
@ -212,6 +213,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}
|
||||||
@ -284,6 +286,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 ; }
|
||||||
|
|
||||||
@ -741,6 +744,90 @@ _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-)
|
||||||
|
if [[ -n "$branch" ]] ; then
|
||||||
|
echo "$branch"
|
||||||
|
else
|
||||||
|
if fossil info &>/dev/null ; then
|
||||||
|
echo "no-tag"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set a color depending on the branch state:
|
||||||
|
# - green if the repository is clean
|
||||||
|
# - red if there is changes to commit
|
||||||
|
# - yellow if the branch has no tag name
|
||||||
|
#
|
||||||
|
# Add the number of impacted files with a
|
||||||
|
# + when files are ADDED or EDITED
|
||||||
|
# - when files are DELETED
|
||||||
|
_lp_fossil_branch_color()
|
||||||
|
{
|
||||||
|
[[ "$LP_ENABLE_FOSSIL" != 1 ]] && return
|
||||||
|
|
||||||
|
local branch
|
||||||
|
branch=$(_lp_fossil_branch)
|
||||||
|
|
||||||
|
if [[ ! -z "$branch" ]] ; then
|
||||||
|
local C2E # Modified files (added or edited)
|
||||||
|
local C2D # Deleted files
|
||||||
|
local C2A # Extras files
|
||||||
|
local ret
|
||||||
|
C2E=$(fossil changes | wc -l)
|
||||||
|
C2D=$(fossil changes | grep DELETED | wc -l)
|
||||||
|
let "C2E = $C2E - $C2D"
|
||||||
|
C2A=$(fossil extras | wc -l)
|
||||||
|
ret=""
|
||||||
|
|
||||||
|
if [[ "$C2E" -gt 0 ]] ; then
|
||||||
|
ret+="+$C2E"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$C2D" -gt 0 ]] ; then
|
||||||
|
if [[ "$ret" = "" ]] ; then
|
||||||
|
ret+="-$C2D"
|
||||||
|
else
|
||||||
|
ret+="/-$C2D"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$C2A" -gt 0 ]] ; then
|
||||||
|
C2A="$LP_MARK_UNTRACKED"
|
||||||
|
else
|
||||||
|
C2A=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$ret" != "" ]] ; then
|
||||||
|
ret="(${LP_COLOR_DIFF}$ret${NO_COL})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$branch" = "no-tag" ]] ; then
|
||||||
|
# Warning, your branch has no tag name !
|
||||||
|
branch="${LP_COLOR_COMMITS}$branch${NO_COL}$ret${LP_COLOR_COMMITS}$C2A${NO_COL}"
|
||||||
|
else
|
||||||
|
if [[ "$C2E" -eq 0 && "$C2D" -eq 0 ]] ; then
|
||||||
|
# All is up-to-date
|
||||||
|
branch="${LP_COLOR_UP}$branch$C2A${NO_COL}"
|
||||||
|
else
|
||||||
|
# There're some changes to commit
|
||||||
|
branch="${LP_COLOR_CHANGES}$branch${NO_COL}$ret${LP_COLOR_CHANGES}$C2A${NO_COL}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo -ne "$branch"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Battery status #
|
# Battery status #
|
||||||
##################
|
##################
|
||||||
@ -945,6 +1032,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}"
|
||||||
}
|
}
|
||||||
@ -1018,6 +1107,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
|
||||||
@ -1042,13 +1132,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}"
|
||||||
|
@ -78,6 +78,10 @@ LP_ENABLE_SVN=1
|
|||||||
# Recommended value is 1
|
# Recommended value is 1
|
||||||
LP_ENABLE_HG=1
|
LP_ENABLE_HG=1
|
||||||
|
|
||||||
|
# Do you want to use the fossil special features ?
|
||||||
|
# Recommended value is 1
|
||||||
|
LP_ENABLE_FOSSIL=1
|
||||||
|
|
||||||
# Show time of the last prompt display
|
# Show time of the last prompt display
|
||||||
# Recommended value is 0
|
# Recommended value is 0
|
||||||
LP_ENABLE_TIME=0
|
LP_ENABLE_TIME=0
|
||||||
|
Loading…
Reference in New Issue
Block a user