The only true value is 1, everything else is false
For boolean variables (there is no such type in shell) we consider that '1' is true, and everything else ('0', ''...) is false. So all tests are now done by comparing the "one true value", '1', and variables expansion is protected with quotes. Affects LP_ENABLE_*, LP_HOSTNAME_ALWAYS.
This commit is contained in:
parent
4b42dffb66
commit
7d4ca77009
26
liquidprompt
26
liquidprompt
@ -316,7 +316,7 @@ _lp_connection()
|
|||||||
# build this just once
|
# build this just once
|
||||||
case "$(_lp_connection)" in
|
case "$(_lp_connection)" in
|
||||||
lcl)
|
lcl)
|
||||||
if [[ $LP_HOSTNAME_ALWAYS == 0 ]] ; then
|
if [[ "$LP_HOSTNAME_ALWAYS" != 1 ]] ; then
|
||||||
LP_HOST="${NO_COL}" # no hostname if local
|
LP_HOST="${NO_COL}" # no hostname if local
|
||||||
else
|
else
|
||||||
LP_HOST="${NO_COL}@${LP_COLOR_HOST}${_LP_HOST_SYMBOL}${NO_COL}"
|
LP_HOST="${NO_COL}@${LP_COLOR_HOST}${_LP_HOST_SYMBOL}${NO_COL}"
|
||||||
@ -525,9 +525,7 @@ _lp_return_value()
|
|||||||
# Get the branch name of the current directory
|
# Get the branch name of the current directory
|
||||||
_lp_git_branch()
|
_lp_git_branch()
|
||||||
{
|
{
|
||||||
if [[ $LP_ENABLE_GIT == 0 ]] ; then
|
[[ "$LP_ENABLE_GIT" == 1 ]] || return
|
||||||
return
|
|
||||||
fi
|
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1 && [[ ! -z "$(git branch)" ]] ; then
|
if git rev-parse --git-dir >/dev/null 2>&1 && [[ ! -z "$(git branch)" ]] ; then
|
||||||
echo -n "$(git branch 2>/dev/null | sed -n '/^\*/s/^\* //p;')"
|
echo -n "$(git branch 2>/dev/null | sed -n '/^\*/s/^\* //p;')"
|
||||||
fi
|
fi
|
||||||
@ -541,9 +539,7 @@ _lp_git_branch()
|
|||||||
# Add the number of pending commits and the impacted lines.
|
# Add the number of pending commits and the impacted lines.
|
||||||
_lp_git_branch_color()
|
_lp_git_branch_color()
|
||||||
{
|
{
|
||||||
if [[ $LP_ENABLE_GIT == 0 ]] ; then
|
[[ "$LP_ENABLE_GIT" == 1 ]] || return
|
||||||
return
|
|
||||||
fi
|
|
||||||
command -v git >/dev/null 2>&1 || return 1;
|
command -v git >/dev/null 2>&1 || return 1;
|
||||||
local branch
|
local branch
|
||||||
branch=$(_lp_git_branch)
|
branch=$(_lp_git_branch)
|
||||||
@ -597,9 +593,7 @@ _lp_git_branch_color()
|
|||||||
# Get the branch name of the current directory
|
# Get the branch name of the current directory
|
||||||
_lp_hg_branch()
|
_lp_hg_branch()
|
||||||
{
|
{
|
||||||
if [[ $LP_ENABLE_HG == 0 ]] ; then
|
[[ "$LP_ENABLE_HG" == 1 ]] || return
|
||||||
return
|
|
||||||
fi
|
|
||||||
local branch
|
local branch
|
||||||
branch="$(hg branch 2>/dev/null)"
|
branch="$(hg branch 2>/dev/null)"
|
||||||
if [[ $? -eq 0 ]] && [[ ! -z "$(hg branch)" ]] ; then
|
if [[ $? -eq 0 ]] && [[ ! -z "$(hg branch)" ]] ; then
|
||||||
@ -613,9 +607,7 @@ _lp_hg_branch()
|
|||||||
# - TODO: yellow if there is some commits not pushed
|
# - TODO: yellow if there is some commits not pushed
|
||||||
_lp_hg_branch_color()
|
_lp_hg_branch_color()
|
||||||
{
|
{
|
||||||
if [[ $LP_ENABLE_HG == 0 ]] ; then
|
[[ "$LP_ENABLE_HG" == 1 ]] || return
|
||||||
return
|
|
||||||
fi
|
|
||||||
command -v hg >/dev/null 2>&1 || return 1;
|
command -v hg >/dev/null 2>&1 || return 1;
|
||||||
local branch
|
local branch
|
||||||
local ret
|
local ret
|
||||||
@ -636,9 +628,7 @@ _lp_hg_branch_color()
|
|||||||
# For the first level of the repository, gives the repository name
|
# For the first level of the repository, gives the repository name
|
||||||
_lp_svn_branch()
|
_lp_svn_branch()
|
||||||
{
|
{
|
||||||
if [[ $LP_ENABLE_SVN == 0 ]] ; then
|
[[ "$LP_ENABLE_SVN" == 1 ]] || return
|
||||||
return
|
|
||||||
fi
|
|
||||||
local infos
|
local infos
|
||||||
local ret
|
local ret
|
||||||
infos=$(svn info --xml 2>/dev/null)
|
infos=$(svn info --xml 2>/dev/null)
|
||||||
@ -665,9 +655,7 @@ _lp_svn_branch()
|
|||||||
# informations are only displayed for the CURRENT directory.
|
# informations are only displayed for the CURRENT directory.
|
||||||
_lp_svn_branch_color()
|
_lp_svn_branch_color()
|
||||||
{
|
{
|
||||||
if [[ $LP_ENABLE_SVN == 0 ]] ; then
|
[[ "$LP_ENABLE_SVN" == 1 ]] || return
|
||||||
return
|
|
||||||
fi
|
|
||||||
command -v svn >/dev/null 2>&1 || return 1;
|
command -v svn >/dev/null 2>&1 || return 1;
|
||||||
local branch
|
local branch
|
||||||
branch=$(_lp_svn_branch)
|
branch=$(_lp_svn_branch)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user