Add a special mark when in a disabled VCS repository

This adds the LP_MARK_DISABLED (default: "⌀"), used as a prompt mark
when in disabled repositories (see `LP_DISABLED_VCS_PATH`).
This commit is contained in:
nojhan 2013-04-22 19:07:34 +02:00
parent ccd417584a
commit d367976932
2 changed files with 36 additions and 19 deletions

View File

@ -297,6 +297,7 @@ Special characters:
* `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_FOSSIL` (default: "⌘") prompt mark in fossil repositories
* `LP_MARK_BZR` (default: "⚯") prompt mark in bazaar repositories * `LP_MARK_BZR` (default: "⚯") prompt mark in bazaar repositories
* `LP_MARK_DISABLED` (default: "⌀") prompt mark in disabled repositories (see `LP_DISABLED_VCS_PATH`)
* `LP_MARK_UNTRACKED` (default: "*") if git has untracked files * `LP_MARK_UNTRACKED` (default: "*") if git has untracked files
* `LP_MARK_STASH` (default: "+") if git has stashed modifications * `LP_MARK_STASH` (default: "+") if git has stashed modifications
* `LP_MARK_BRACKET_OPEN` (default: "[") marks around the main part of the prompt * `LP_MARK_BRACKET_OPEN` (default: "[") marks around the main part of the prompt

View File

@ -237,6 +237,7 @@ _lp_source_config()
LP_MARK_GIT=${LP_MARK_GIT:-"±"} LP_MARK_GIT=${LP_MARK_GIT:-"±"}
LP_MARK_FOSSIL=${LP_MARK_FOSSIL:-"⌘"} LP_MARK_FOSSIL=${LP_MARK_FOSSIL:-"⌘"}
LP_MARK_BZR=${LP_MARK_BZR:-"⚯"} LP_MARK_BZR=${LP_MARK_BZR:-"⚯"}
LP_MARK_DISABLED=${LP_MARK_DISABLED:-"⌀"}
LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"} LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"}
LP_MARK_STASH=${LP_MARK_STASH:-"+"} LP_MARK_STASH=${LP_MARK_STASH:-"+"}
LP_MARK_BRACKET_OPEN=${LP_MARK_BRACKET_OPEN:-"["} LP_MARK_BRACKET_OPEN=${LP_MARK_BRACKET_OPEN:-"["}
@ -1274,6 +1275,8 @@ _lp_smart_mark()
mark=$LP_MARK_FOSSIL mark=$LP_MARK_FOSSIL
elif [[ "$1" == "bzr" ]]; then elif [[ "$1" == "bzr" ]]; then
mark=$LP_MARK_BZR mark=$LP_MARK_BZR
elif [[ "$1" == "disabled" ]]; then
mark=$LP_MARK_DISABLED
fi fi
echo -ne "${COL}${mark}${NO_COL}" echo -ne "${COL}${mark}${NO_COL}"
} }
@ -1382,8 +1385,10 @@ _lp_set_prompt()
# right of main prompt: space at left # right of main prompt: space at left
LP_VENV=$(_lp_sl "$(_lp_virtualenv)") LP_VENV=$(_lp_sl "$(_lp_virtualenv)")
LP_VCS="" # if change of working directory
if [[ "$LP_OLD_PWD" != "$PWD" ]]; then if [[ "$LP_OLD_PWD" != "$PWD" ]]; then
LP_VCS=""
LP_VCS_TYPE=""
# LP_HOST is a global set at load time # LP_HOST is a global set at load time
LP_PERM=$(_lp_permissions_color) LP_PERM=$(_lp_permissions_color)
LP_PWD=$(_lp_shorten_path) LP_PWD=$(_lp_shorten_path)
@ -1391,38 +1396,47 @@ _lp_set_prompt()
if [[ "$(_lp_are_vcs_disabled)" -eq "0" ]] ; then if [[ "$(_lp_are_vcs_disabled)" -eq "0" ]] ; then
LP_VCS="$(_lp_git_branch_color)" LP_VCS="$(_lp_git_branch_color)"
LP_VCS_TYPES="git" LP_VCS_TYPE="git"
if [[ -n "$LP_VCS" ]]; then if [[ -n "$LP_VCS" ]]; then
# If this is a git-svn repository # If this is a git-svn repository
if [[ -d "$(git rev-parse --git-dir 2>/dev/null)/svn" ]]; then if [[ -d "$(git rev-parse --git-dir 2>/dev/null)/svn" ]]; then
LP_VCS_TYPES="git-svn" LP_VCS_TYPE="git-svn"
fi fi
fi # git-svn fi # git-svn
if [[ -z "$LP_VCS" ]]; then if [[ -z "$LP_VCS" ]]; then
LP_VCS="$(_lp_hg_branch_color)" LP_VCS="$(_lp_hg_branch_color)"
LP_VCS_TYPES="hg" LP_VCS_TYPE="hg"
if [[ -z "$LP_VCS" ]]; then if [[ -z "$LP_VCS" ]]; then
LP_VCS="$(_lp_svn_branch_color)" LP_VCS="$(_lp_svn_branch_color)"
LP_VCS_TYPES="svn" LP_VCS_TYPE="svn"
if [[ -z "$LP_VCS" ]]; then if [[ -z "$LP_VCS" ]]; then
LP_VCS="$(_lp_fossil_branch_color)" LP_VCS="$(_lp_fossil_branch_color)"
LP_VCS_TYPES="fossil" LP_VCS_TYPE="fossil"
if [[ -z "$LP_VCS" ]]; then if [[ -z "$LP_VCS" ]]; then
LP_VCS="$(_lp_bzr_branch_color)" LP_VCS="$(_lp_bzr_branch_color)"
LP_VCS_TYPES="bzr" LP_VCS_TYPE="bzr"
if [[ -z "$LP_VCS" ]]; then
LP_VCS=""
LP_VCS_TYPE=""
fi # nothing
fi # bzr fi # bzr
fi # fossil fi # fossil
fi # svn fi # svn
fi # hg fi # hg
fi # disabled
if [[ -z "$LP_VCS" ]] ; then else # if this vcs rep is disabled
LP_VCS_TYPES="" LP_VCS="" # not necessary, but more readable
LP_VCS_TYPE="disabled"
fi
if [[ -z "$LP_VCS_TYPE" ]] ; then
LP_VCS=""
else else
LP_VCS=$(_lp_sl "${LP_VCS}") LP_VCS=$(_lp_sl "${LP_VCS}")
fi fi
# end of the prompt line: double spaces # end of the prompt line: double spaces
LP_MARK=$(_lp_sb "$(_lp_smart_mark $LP_VCS_TYPES)") LP_MARK=$(_lp_sb "$(_lp_smart_mark $LP_VCS_TYPE)")
# Different path color if root # Different path color if root
if [[ "$EUID" -ne "0" ]] ; then if [[ "$EUID" -ne "0" ]] ; then
@ -1432,14 +1446,16 @@ _lp_set_prompt()
fi fi
LP_OLD_PWD="$PWD" LP_OLD_PWD="$PWD"
elif [[ -n "$LP_VCS_TYPES" ]]; then # if do not change of working directory but...
case "$LP_VCS_TYPES" in elif [[ -n "$LP_VCS_TYPE" ]]; then # we are still in a VCS dir
git) LP_VCS=$(_lp_sl "$(_lp_git_branch_color)");; case "$LP_VCS_TYPE" in
git-svn)LP_VCS=$(_lp_sl "$(_lp_git_branch_color)");; git) LP_VCS=$(_lp_sl "$(_lp_git_branch_color)");;
hg) LP_VCS=$(_lp_sl "$(_lp_hg_branch_color)");; git-svn) LP_VCS=$(_lp_sl "$(_lp_git_branch_color)");;
svn) LP_VCS=$(_lp_sl "$(_lp_svn_branch_color)");; hg) LP_VCS=$(_lp_sl "$(_lp_hg_branch_color)");;
fossil) LP_VCS=$(_lp_sl "$(_lp_fossil_branch_color)");; svn) LP_VCS=$(_lp_sl "$(_lp_svn_branch_color)");;
bzr) LP_VCS=$(_lp_sl "$(_lp_bzr_branch_color)");; fossil) LP_VCS=$(_lp_sl "$(_lp_fossil_branch_color)");;
bzr) LP_VCS=$(_lp_sl "$(_lp_bzr_branch_color)");;
disabled)LP_VCS="";;
esac esac
fi fi