Merge remote branch 'upstream/master'
Conflicts: liquidprompt.bash
This commit is contained in:
commit
a114b8ccc4
21
README.md
21
README.md
@ -53,18 +53,35 @@ there is changes, in yellow if there is pending commits to push;
|
||||
* a smart mark: ± for VCS directories, $ for simple user, a red # for root.
|
||||
|
||||
|
||||
## USAGE
|
||||
## INSTALL
|
||||
|
||||
Include the file in your bash configuration, for example in your `.bashrc`:
|
||||
|
||||
`source liquidprompt.bash`
|
||||
|
||||
Copy the `liquidpromptrc-dist` file in your home directory as
|
||||
`~/.liquidpromptrc` and edit it according to your preferences. If you skip this
|
||||
step, the default behaviour will be used.
|
||||
|
||||
|
||||
## PUT THE PROMPT IN A DIFFERENT ORDER
|
||||
|
||||
You can configure some variables in the `~/.liquidpromptrc` file:
|
||||
|
||||
* `LP_BATTERY_THRESHOLD`, the maximal value under which the battery level is
|
||||
displayed
|
||||
* `LP_LOAD_THRESHOLD`, the minimal value after which the load average is
|
||||
displayed
|
||||
* `LP_PATH_LENGTH`, the maximum percentage of the screen width used to display
|
||||
the path
|
||||
* `LP_PATH_KEEP`, how many directories to keep at the beginning of a shortened
|
||||
path
|
||||
* `LP_REVERSE`, choose between reverse colors (black on white) instead of normal
|
||||
theme (white on black)
|
||||
|
||||
Most of the display is prepared in the `__set_bash_prompt` function, apart from
|
||||
features that needs several colors (such as the load colormap). You can sort
|
||||
what you want to see by editing the PS1 variable.
|
||||
what you want to see by editing the PS1 variable here.
|
||||
|
||||
|
||||
## KNOWN LIMITATIONS AND BUGS
|
||||
|
@ -49,25 +49,13 @@ unset bash bmajor bminor
|
||||
# CONFIGURATION #
|
||||
#################
|
||||
|
||||
# Maximal value under which the battery level is displayed
|
||||
# Recommended value is 75
|
||||
BATTERY_THRESHOLD=75
|
||||
LP_BATTERY_THRESHOLD=75
|
||||
LP_LOAD_THRESHOLD=60
|
||||
LP_PATH_LENGTH=35
|
||||
LP_PATH_KEEP=2
|
||||
LP_REVERSE=0
|
||||
|
||||
# Minimal value after which the load average is displayed
|
||||
# Recommended value is 60
|
||||
LOAD_THRESHOLD=60
|
||||
|
||||
# The maximum percentage of the screen width used to display the path
|
||||
# Recommended value is 35
|
||||
PATH_LENGTH=35
|
||||
|
||||
# How many directories to keep at the beginning of a shortened path
|
||||
# Recommended value is 2
|
||||
PATH_KEEP=2
|
||||
|
||||
# Do we use reverse colors (black on white) instead of normal theme (white on black)
|
||||
# Defaults to unset (white on black)
|
||||
# Otherwise use REVERSE="1" source liquidprompt.bash
|
||||
source ~/.liquidpromptrc 2> /dev/null
|
||||
|
||||
|
||||
###############
|
||||
@ -149,7 +137,7 @@ fi
|
||||
# can be set to white or black
|
||||
FG=$WHITE
|
||||
BOLD_FG=$BOLD_WHITE
|
||||
if [[ $REVERSE ]] ; then
|
||||
if [[ $LP_REVERSE == 1 ]] ; then
|
||||
FG=$BLACK
|
||||
BOLD_FG=$BOLD_GRAY
|
||||
fi
|
||||
@ -168,7 +156,7 @@ __cpunum_FreeBSD()
|
||||
|
||||
__cpunum_Darwin()
|
||||
{
|
||||
__cpunum_FreeBSD
|
||||
__cpunum_FreeBSD
|
||||
}
|
||||
|
||||
__cpunum_SunOS()
|
||||
@ -195,7 +183,7 @@ __load_FreeBSD()
|
||||
|
||||
__load_Darwin()
|
||||
{
|
||||
__load_FreeBSD
|
||||
__load_FreeBSD
|
||||
}
|
||||
|
||||
__load_SunOS()
|
||||
@ -299,13 +287,20 @@ __shorten_path()
|
||||
# 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)
|
||||
local keep=$((PATH_KEEP-1))
|
||||
local keep=$((LP_PATH_KEEP-1))
|
||||
|
||||
local len_percent=$2
|
||||
|
||||
local p=$(echo "$1" | sed -e "s|$HOME|~|")
|
||||
local len="${#p}"
|
||||
local max_len=$(($COLUMNS*$len_percent/100))
|
||||
|
||||
if [ -z "$COLUMNS" ]
|
||||
then
|
||||
local columns=80
|
||||
else
|
||||
local columns=$COLUMNS
|
||||
fi
|
||||
local max_len=$(($columns*$len_percent/100))
|
||||
local mask_len="${#mask}"
|
||||
|
||||
if [[ "$len" -gt "$max_len" ]]
|
||||
@ -556,7 +551,7 @@ __battery()
|
||||
if [[ "${bat}" == "" ]] ; then
|
||||
return 1
|
||||
fi
|
||||
if [[ ${bat} -le $BATTERY_THRESHOLD ]] ; then
|
||||
if [[ ${bat} -le $LP_BATTERY_THRESHOLD ]] ; then
|
||||
echo -n "${bat}"
|
||||
return 0
|
||||
else
|
||||
@ -571,7 +566,7 @@ __battery_color()
|
||||
if [[ "$?" = "1" ]] ; then return; fi; # no battery support
|
||||
|
||||
if [[ "$bat" != "" ]] ; then
|
||||
if [[ ${bat} -gt $BATTERY_THRESHOLD ]] ; then
|
||||
if [[ ${bat} -gt $LP_BATTERY_THRESHOLD ]] ; then
|
||||
return; # nothing displayed above 75%
|
||||
fi
|
||||
|
||||
@ -614,7 +609,7 @@ __load_color()
|
||||
fi
|
||||
let "load=$load/$__CPUNUM"
|
||||
|
||||
if [[ $load -ge $LOAD_THRESHOLD ]]
|
||||
if [[ $load -ge $LP_LOAD_THRESHOLD ]]
|
||||
then
|
||||
ret="l${NO_COL}"
|
||||
if [[ $load -lt 70 ]] ; then
|
||||
@ -702,7 +697,7 @@ __set_bash_prompt()
|
||||
__USER=$(__user)
|
||||
__HOST=$(__host_color)
|
||||
__PERM=$(__permissions_color)
|
||||
__PWD=$(__shorten_path "$PWD" $PATH_LENGTH)
|
||||
__PWD=$(__shorten_path $PWD $LP_PATH_LENGTH)
|
||||
|
||||
# right of main prompt: space at left
|
||||
__GIT=$(__sl "$(__git_branch_color)")
|
||||
|
26
liquidpromptrc-dist
Normal file
26
liquidpromptrc-dist
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
####################################
|
||||
# LIQUID PROMPT CONFIGURATION FILE #
|
||||
####################################
|
||||
|
||||
# Maximal value under which the battery level is displayed
|
||||
# Recommended value is 75
|
||||
LP_BATTERY_THRESHOLD=75
|
||||
|
||||
# Minimal value after which the load average is displayed
|
||||
# Recommended value is 60
|
||||
LP_LOAD_THRESHOLD=60
|
||||
|
||||
# The maximum percentage of the screen width used to display the path
|
||||
# Recommended value is 35
|
||||
LP_PATH_LENGTH=35
|
||||
|
||||
# How many directories to keep at the beginning of a shortened path
|
||||
# Recommended value is 2
|
||||
LP_PATH_KEEP=2
|
||||
|
||||
# Do we use reverse colors (black on white) instead of normal theme (white on black)
|
||||
# Defaults to 0 (normal colors)
|
||||
# set to 1 if you use black on white
|
||||
LP_REVERSE=0
|
||||
|
Loading…
Reference in New Issue
Block a user