Allow to disable load, battery, etc. in the rc file
Yes, much more config options, but it allows to lighten the prompt and so improve its speed. I wanted to detect the useful parts by parsing the theme but it seems impossible (I didn't find how).
This commit is contained in:
parent
4b1f4646de
commit
05fcbe909a
14
README.md
14
README.md
@ -106,6 +106,20 @@ the path
|
||||
path
|
||||
* `LP_HOSTNAME_ALWAYS`, choose between always displaying the hostname or showing
|
||||
it only when connected with a remote shell
|
||||
* `LP_ENABLE_PERM`, if you want to detect if the directory is writable
|
||||
* `LP_ENABLE_SHORTEN_PATH`, if you to shorten the path display
|
||||
* `LP_ENABLE_PROXY`, if you want to detect if a proxy is used
|
||||
* `LP_ENABLE_JOBS`, if you want to have jobs informations
|
||||
* `LP_ENABLE_LOAD`, if you want to have load informations
|
||||
* `LP_ENABLE_BATT`, if you want to have battery informations
|
||||
* `LP_ENABLE_GIT`, if you want to have git informations
|
||||
* `LP_ENABLE_SVN`, if you want to have subversion informations
|
||||
* `LP_ENABLE_HG`, if you want to have mercurial informations
|
||||
|
||||
Please note that all the `LP_ENABLE_…` variables override the templates, ie if you use `$LP_BATT` in your template and
|
||||
you set `LP_ENABLE_BATT=0` in your config file, you will not have the battery informations.
|
||||
|
||||
# vim: set et sts=4 sw=4 tw=120 ft=sh:
|
||||
|
||||
|
||||
## PUT THE PROMPT IN A DIFFERENT ORDER
|
||||
|
46
liquidprompt
46
liquidprompt
@ -218,6 +218,12 @@ LP_PROXY_MARK=${LP_PROXY_MARK:-"↥"}
|
||||
LP_GIT_MARK=${LP_GIT_MARK:-"±"}
|
||||
LP_MERCURIAL_MARK=${LP_MERCURIAL_MARK:-"☿"}
|
||||
LP_SUBVERSION_MARK=${LP_SUBVERSION_MARK:-"‡"}
|
||||
LP_ENABLE_PERM=${LP_ENABLE_PERM:-1}
|
||||
LP_ENABLE_SHORTEN_PATH=${LP_ENABLE_SHORTEN_PATH:-1}
|
||||
LP_ENABLE_PROXY=${LP_ENABLE_PROXY:-1}
|
||||
LP_ENABLE_JOBS=${LP_ENABLE_JOBS:-1}
|
||||
LP_ENABLE_LOAD=${LP_ENABLE_LOAD:-1}
|
||||
LP_ENABLE_BATT=${LP_ENABLE_BATT:-1}
|
||||
LP_ENABLE_GIT=${LP_ENABLE_GIT:-1}
|
||||
LP_ENABLE_SVN=${LP_ENABLE_SVN:-1}
|
||||
LP_ENABLE_HG=${LP_ENABLE_HG:-1}
|
||||
@ -361,6 +367,10 @@ unset _lp_connection
|
||||
# put an arrow if an http proxy is set
|
||||
_lp_proxy()
|
||||
{
|
||||
if [[ $LP_ENABLE_PROXY == 0 ]] ; then
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
if [[ ! -z "$http_proxy" ]] ; then
|
||||
echo -ne $LP_PROXY_MARK
|
||||
fi
|
||||
@ -380,6 +390,10 @@ _lp_proxy()
|
||||
# + keep some left part of the path if asked
|
||||
_lp_shorten_path()
|
||||
{
|
||||
if [[ $LP_ENABLE_SHORTEN_PATH == 0 ]] ; then
|
||||
echo $(echo "$1" | sed -e "s|$HOME|~|")
|
||||
return
|
||||
fi
|
||||
# the character that will replace the part of the path that is masked
|
||||
local mask=" … "
|
||||
# index of the directory to keep from the root (starts at 0 whith bash, 1 with zsh)
|
||||
@ -471,7 +485,7 @@ _lp_shorten_path()
|
||||
# colored in red if it have not.
|
||||
_lp_permissions_color()
|
||||
{
|
||||
if [[ -w "${PWD}" ]]; then
|
||||
if [[ -w "${PWD}" || $LP_ENABLE_PERM == 0 ]]; then
|
||||
echo "${LP_COLOR_WRITE}:${NO_COL}"
|
||||
else
|
||||
echo "${LP_COLOR_NOWRITE}:${NO_COL}"
|
||||
@ -488,6 +502,10 @@ _lp_permissions_color()
|
||||
# or detached screens sessions running on the host
|
||||
_lp_jobcount_color()
|
||||
{
|
||||
if [[ $LP_ENABLE_JOBS == 0 ]] ; then
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
local running=$(( $(jobs -r | wc -l) ))
|
||||
local stopped=$(( $(jobs -s | wc -l) ))
|
||||
local screens=$(screen -ls 2> /dev/null | grep -c Detach )
|
||||
@ -547,7 +565,8 @@ _lp_return_value()
|
||||
_lp_git_branch()
|
||||
{
|
||||
if [[ $LP_ENABLE_GIT == 0 ]] ; then
|
||||
return ""
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
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;')"
|
||||
@ -563,7 +582,8 @@ _lp_git_branch()
|
||||
_lp_git_branch_color()
|
||||
{
|
||||
if [[ $LP_ENABLE_GIT == 0 ]] ; then
|
||||
return ""
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
command -v git >/dev/null 2>&1 || return 1;
|
||||
local branch
|
||||
@ -611,7 +631,8 @@ _lp_git_branch_color()
|
||||
_lp_hg_branch()
|
||||
{
|
||||
if [[ $LP_ENABLE_HG == 0 ]] ; then
|
||||
return ""
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
local branch
|
||||
branch="$(hg branch 2>/dev/null)"
|
||||
@ -627,7 +648,8 @@ _lp_hg_branch()
|
||||
_lp_hg_branch_color()
|
||||
{
|
||||
if [[ $LP_ENABLE_HG == 0 ]] ; then
|
||||
return ""
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
command -v hg >/dev/null 2>&1 || return 1;
|
||||
local branch
|
||||
@ -650,7 +672,8 @@ _lp_hg_branch_color()
|
||||
_lp_svn_branch()
|
||||
{
|
||||
if [[ $LP_ENABLE_SVN == 0 ]] ; then
|
||||
return ""
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
local infos
|
||||
local ret
|
||||
@ -679,7 +702,8 @@ _lp_svn_branch()
|
||||
_lp_svn_branch_color()
|
||||
{
|
||||
if [[ $LP_ENABLE_SVN == 0 ]] ; then
|
||||
return ""
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
command -v svn >/dev/null 2>&1 || return 1;
|
||||
local branch
|
||||
@ -754,6 +778,10 @@ _lp_battery()
|
||||
# a red ⌁ if the battery is discharging and above threshold
|
||||
_lp_battery_color()
|
||||
{
|
||||
if [[ $LP_ENABLE_BATT == 0 ]] ; then
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
local mark=$LP_BATTERY_MARK
|
||||
local chargingmark=$LP_ADAPTER_MARK
|
||||
local bat
|
||||
@ -830,6 +858,10 @@ _lp_load_color()
|
||||
# Then we have to choose the values at which the colours switch, with
|
||||
# anything past yellow being pretty important.
|
||||
|
||||
if [[ $LP_ENABLE_LOAD == 0 ]] ; then
|
||||
echo -n ''
|
||||
return
|
||||
fi
|
||||
local loadval
|
||||
local load
|
||||
loadval=$(_lp_load_$LP_OS)
|
||||
|
@ -28,6 +28,30 @@ LP_PATH_KEEP=2
|
||||
# set to 1 if you want to always see the hostname
|
||||
LP_HOSTNAME_ALWAYS=0
|
||||
|
||||
# Do you want to use the permissions feature ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_PERM=1
|
||||
|
||||
# Do you want to use the shorten path feature ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_SHORTEN_PATH=1
|
||||
|
||||
# Do you want to use the proxy detection feature ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_PROXY=1
|
||||
|
||||
# Do you want to use the jobs feature ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_JOBS=1
|
||||
|
||||
# Do you want to use the load feature ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_LOAD=1
|
||||
|
||||
# Do you want to use the batt feature ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_BATT=1
|
||||
|
||||
# Do you want to use the git special features ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_GIT=1
|
||||
|
Loading…
Reference in New Issue
Block a user