Different prompt mark for different VCS (±, ☿, ‡)
± for git directories, ☿ for mercurial, ‡ for svn. Thus, do not display the now useless letter prefix before the branch name. Refactor the smart mark function.
This commit is contained in:
parent
8fd5c95409
commit
0943eb67a9
@ -24,7 +24,7 @@ in a git repository on a server, at branch "myb":
|
||||
|
||||
A liquid prompt displaying everything may look like this:
|
||||
|
||||
`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ g·master(+10/-5,3) 125 ± `
|
||||
`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ master(+10/-5,3) 125 ± `
|
||||
|
||||
It displays:
|
||||
|
||||
@ -52,7 +52,8 @@ there is changes, in yellow if there is pending commits to push;
|
||||
* the number of added/deleted lines, if changes have been made and the number
|
||||
of pending commits, if any;
|
||||
* the error code of the last command, if it has failed in some way;
|
||||
* a smart mark: ± for VCS directories, $ for simple user, a red # for root.
|
||||
* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, $ for simple
|
||||
user, a red # for root.
|
||||
|
||||
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.
|
||||
|
@ -502,7 +502,7 @@ __git_branch_color()
|
||||
ret="${GREEN}${branch}${NO_COL}" # nothing to commit or push
|
||||
fi
|
||||
fi
|
||||
echo -ne "g·$ret"
|
||||
echo -ne "$ret"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ __hg_branch_color()
|
||||
else
|
||||
ret="${RED}${branch}${NO_COL}" # changes to commit
|
||||
fi
|
||||
echo -ne "h·$ret"
|
||||
echo -ne "$ret"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -573,7 +573,7 @@ __svn_branch_color()
|
||||
else
|
||||
ret="${RED}${branch}${NO_COL}(${YELLOW}$commits${NO_COL})" # changes to commit
|
||||
fi
|
||||
echo -ne "s·$ret"
|
||||
echo -ne "$ret"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -675,24 +675,24 @@ __load_color()
|
||||
# DESIGN #
|
||||
##########
|
||||
|
||||
# Set the prompt mark to ± if VCS, # if root and else $
|
||||
# FIXME use the mercury unicode char for mercurial
|
||||
# Set the prompt mark to ± if git, to ☿ if mercurial, to ‡ if subversion
|
||||
# to # if root and else $
|
||||
__smart_mark()
|
||||
{
|
||||
if [[ "$EUID" -ne "0" ]]
|
||||
then
|
||||
if [[ ! -z $(__git_branch) ]] || [[ ! -z $(__hg_branch) ]] || [[ ! -z $(__svn_branch) ]] ; then
|
||||
echo -ne "${BOLD_FG}±${NO_COL}"
|
||||
else
|
||||
echo -ne "${BOLD_FG}\\\$${NO_COL}"
|
||||
fi
|
||||
else
|
||||
if [[ ! -z $(__git_branch) ]] || [[ ! -z $(__hg_branch) ]] || [[ ! -z $(__svn_branch) ]] ; then
|
||||
echo -ne "${BOLD_RED}±${NO_COL}"
|
||||
else
|
||||
echo -ne "${BOLD_RED}#${NO_COL}"
|
||||
fi
|
||||
local COL=${BOLD_FG}
|
||||
if [[ "$EUID" -eq "0" ]] ; then
|
||||
COL=${BOLD_RED}
|
||||
fi
|
||||
|
||||
local mark="\\\$"
|
||||
if [[ ! -z $(__git_branch) ]] ; then
|
||||
mark="±"
|
||||
elif [[ ! -z $(__hg_branch) ]] ; then
|
||||
mark="☿"
|
||||
elif [[ ! -z $(__svn_branch) ]] ; then
|
||||
mark="‡"
|
||||
fi
|
||||
echo -ne "${COL}${mark}${NO_COL}"
|
||||
}
|
||||
|
||||
# insert a space on the right
|
||||
|
Loading…
Reference in New Issue
Block a user