add examples an explanations on how to make themes

This commit is contained in:
nojhan 2012-08-14 15:38:33 +02:00
parent 660bc29d8c
commit c90f31351c
5 changed files with 175 additions and 104 deletions

View File

@ -92,7 +92,7 @@ For other features, the script uses commands that should be available on a large
variety of unixes: `tput`, `grep`, `awk`, `sed`, `ps`, `who`.
## PUT THE PROMPT IN A DIFFERENT ORDER
## FEATURES CONFIGURATION
You can configure some variables in the `~/.liquidpromptrc` file:
@ -107,11 +107,39 @@ path
* `LP_HOSTNAME_ALWAYS`, choose between always displaying the hostname or showing
it only when connected with a remote shell
You can sort what you want to see by exporting the `LP_PS1` variable, using the
variables you will found in the `_lp_set_bash_prompt` function.
## PUT THE PROMPT IN A DIFFERENT ORDER
You can sort what you want to see by sourcing your favorite template file
(`*.ps1`), after having sourced the liquid prompt.
Those scripts basically export the `LP_PS1` variable, by appending features and
theme colors.
Available features:
* `LP_BATT` battery
* `LP_LOAD` load
* `LP_JOBS` screen sessions/running jobs/suspended jobs
* `LP_USER` user
* `LP_HOST` hostname
* `LP_PERM` a colon ":"
* `LP_PWD` current working directory
* `LP_PROXY` HTTP proxy
* `LP_GIT` git
* `LP_HG` mercurial
* `LP_SVN` subversion
* `LP_ERR` last error code
* `LP_MARK` prompt mark
Some indicators are not colored by default (mainly those that are _static_), to
put colors on theme you should not forget to add themed colors variable around
them:
LP_PS1="${LP_ERR}" # no color
LP_PS1="${LP_COLOR_ERR}${LP_ERR}${NO_COL}" # colored
For example, if you just want to have a liquidprompt displaying the user and the
host, with a normal path in blue and only the git support:
host, with a normal full path in blue and only the git support:
export LP_PS1=`echo -ne "[\${LP_USER}\${LP_HOST}:\${BLUE}\$(pwd)\${NO_COL}] \${LP_GIT} \\\$ "`
@ -125,13 +153,14 @@ To erase your new formatting, just bring the `LP_PS1` to a null string:
## COLOR THEMES
You can change the colors of some part of the liquid prompt by changing the
following parameters in the config file.
You can change the colors of some part of the liquid prompt by sourcing your
favorite theme file (`*.theme`), before or after having sourced the liquid prompt.
Available colors are:
BOLD, BLACK, BOLD_GRAY, WHITE, BOLD_WHITE,
GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE, BOLD_BLUE, PINK, CYAN, BOLD_CYAN
RED, BOLD_RED, WARN_RED, CRIT_RED, DANGER_RED,
NO_COL.
Set to a null string "" if you do not want color.
* Current working directory

41
liquid.ps1 Normal file
View File

@ -0,0 +1,41 @@
#######################################
# LIQUID PROMPT DEFAULT TEMPLATE FILE #
#######################################
# Available features:
# LP_BATT battery
# LP_LOAD load
# LP_JOBS screen sessions/running jobs/suspended jobs
# LP_USER user
# LP_HOST hostname
# LP_PERM a colon ":"
# LP_PWD current working directory
# LP_PROXY HTTP proxy
# LP_GIT git
# LP_HG mercurial
# LP_SVN subversion
# LP_ERR last error code
# LP_MARK prompt mark
# add jobs, load and battery
LP_PS1="${LP_BATT}${LP_LOAD}${LP_JOBS}"
# add user, host and permissions colon
LP_PS1="${LP_PS1}[${LP_USER}${LP_HOST}${LP_PERM}"
# if not root
if [[ "$EUID" -ne "0" ]]
then
# path in foreground color
LP_PS1="${LP_PS1}${LP_COLOR_PATH}${LP_PWD}${NO_COL}]${LP_COLOR_PROXY}${LP_PROXY}${NO_COL}"
# add VCS infos
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}"
else
# path in yellow
LP_PS1="${LP_PS1}${LP_PATH_ROOT}${LP_PWD}${NO_COL}]${LP_COLOR_PROXY}${LP_PROXY}${NO_COL}"
# do not add VCS infos
fi
# add return code and prompt mark
LP_PS1="${LP_PS1}${LP_COLOR_ERR}${LP_ERR}${NO_COL}${LP_MARK}"
# vim: set ts=4 sw=4 tw=120 ft=sh:

96
liquid.theme Normal file
View File

@ -0,0 +1,96 @@
####################################
# LIQUID PROMPT DEFAULT THEME FILE #
####################################
# Special characters
# Be sure to use characters that exists in the font you use. You can use several
# characters at once.
# Below is an example of how to fallback to ascii if the term is not unicode capable.
# Defaults to UTF-8 characters.
if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]] ; then
# If charset is UTF-8.
LP_BATTERY_MARK="⌁" # in front of the battery charge
LP_ADAPTER_MARK="⏚" # displayed when plugged
LP_LOAD_MARK="⌂" # in front of the load
LP_PROXY_MARK="↥" # indicate a proxy in use
LP_GIT_MARK="±" # prompt mark in git repositories
LP_MERCURIAL_MARK="☿" # prompt mark in hg repositories
LP_SUBVERSION_MARK="‡" # prompt mark in svn repositories
else
# If charset is anything else, fallback to ASCII chars
LP_BATTERY_MARK="b"
LP_ADAPTER_MARK="p"
LP_LOAD_MARK="c"
LP_PROXY_MARK="^"
LP_GIT_MARK="+"
LP_MERCURIAL_MARK="m"
LP_SUBVERSION_MARK="="
fi
# Colors
# Available colors are:
# BOLD, BLACK, BOLD_GRAY, WHITE, BOLD_WHITE,
# GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE, BOLD_BLUE, PINK, CYAN, BOLD_CYAN
# RED, BOLD_RED, WARN_RED, CRIT_RED, DANGER_RED,
# Set to a null string "" if you do not want color.
# Current working directory
LP_COLOR_PATH="$BOLD_WHITE" # as normal user
LP_COLOR_PATH_ROOT="$BOLD_YELLOW" # as root
# Color of the proxy mark
LP_COLOR_PROXY="$BOLD_BLUE"
# Jobs count
LP_COLOR_JOB_D="$YELLOW" # Detached (aka screen sessions)
LP_COLOR_JOB_R="$BOLD_YELLOW" # Running (xterm &)
LP_COLOR_JOB_Z="$BOLD_YELLOW" # Sleeping (Ctrl-Z)
# Last error code
LP_COLOR_ERR="$PURPLE"
# Prompt mark
LP_COLOR_MARK="$BOLD_WHITE" # as user
LP_COLOR_MARK_ROOT="$BOLD_RED" # as root
# Current user
LP_COLOR_USER_LOGGED="" # user who logged in
LP_COLOR_USER_ALT="$BOLD" # user but not the one who logged in
LP_COLOR_USER_ROOT="$BOLD_YELLOW" # root
# Hostname
LP_COLOR_HOST="" # local host
LP_COLOR_SSH="$BOLD_CYAN" # connected via SSH
LP_COLOR_TELNET="$WARN_RED" # connected via telnet
# Separation mark (aka permiison in the working dir)
LP_COLOR_WRITE="$GREEN" # have write permission
LP_COLOR_NOWRITE="$RED" # do not have write permission
# VCS
LP_COLOR_UP="$GREEN" # repository is up to date / a push have been made
LP_COLOR_COMMITS="$YELLOW" # some commits have not been pushed
LP_COLOR_CHANGES="$RED" # there is some changes to commit
LP_COLOR_DIFF="$PURPLE" # number of lines impacted by current changes
# Battery
LP_COLOR_CHARGING_ABOVE="$GREEN" # charging and above threshold
LP_COLOR_CHARGING_UNDER="$YELLOW" # charging but under threshold
LP_COLOR_DISCHARGING_ABOVE="$YELLOW" # discharging but above threshold
LP_COLOR_DISCHARGING_UNDER="$RED" # discharging and under threshold
# Color maps (battery and load levels)
# Range from 0 (nothing special) to 9 (alert)
LP_COLORMAP_0=""
LP_COLORMAP_1="$GREEN"
LP_COLORMAP_2="$BOLD_GREEN"
LP_COLORMAP_3="$YELLOW"
LP_COLORMAP_4="$BOLD_YELLOW"
LP_COLORMAP_5="$RED"
LP_COLORMAP_6="$BOLD_RED"
LP_COLORMAP_7="$WARN_RED"
LP_COLORMAP_8="$CRIT_RED"
LP_COLORMAP_9="$DANGER_RED"
# vim: set ts=4 sw=4 tw=120 ft=sh:

View File

@ -934,7 +934,7 @@ _lp_sb()
_lp_set_bash_prompt()
{
# as this get the last returned code, it should be called first
LP_RET=$(_lp_sl "$(_lp_return_value $?)")
LP_ERR=$(_lp_sl "$(_lp_return_value $?)")
# execute the old prompt
$LP_OLD_PROMPT_COMMAND
@ -978,7 +978,7 @@ _lp_set_bash_prompt()
# do not add VCS infos
fi
# add return code and prompt mark
PS1="${PS1}${LP_COLOR_ERR}${LP_RET}${NO_COL}${LP_MARK}"
PS1="${PS1}${LP_COLOR_ERR}${LP_ERR}${NO_COL}${LP_MARK}"
# Glue the bash prompt always go to the first column.
# Avoid glitches after interrupting a command with Ctrl-C

View File

@ -28,99 +28,4 @@ LP_PATH_KEEP=2
# set to 1 if you want to always see the hostname
LP_HOSTNAME_ALWAYS=0
##########
# THEMES #
##########
# Special characters
# Be sure to use characters that exists in the font you use. You can use several
# characters at once.
# Below is an example of how to fallback to ascii if the term is not unicode capable.
# Defaults to UTF-8 characters.
if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]] ; then
# If charset is UTF-8.
LP_BATTERY_MARK="⌁" # in front of the battery charge
LP_ADAPTER_MARK="⏚" # displayed when plugged
LP_LOAD_MARK="⌂" # in front of the load
LP_PROXY_MARK="↥" # indicate a proxy in use
LP_GIT_MARK="±" # prompt mark in git repositories
LP_MERCURIAL_MARK="☿" # prompt mark in hg repositories
LP_SUBVERSION_MARK="‡" # prompt mark in svn repositories
else
# If charset is anything else, fallback to ASCII chars
LP_BATTERY_MARK="b"
LP_ADAPTER_MARK="p"
LP_LOAD_MARK="c"
LP_PROXY_MARK="^"
LP_GIT_MARK="+"
LP_MERCURIAL_MARK="m"
LP_SUBVERSION_MARK="="
fi
# Colors
# Available colors are:
# BOLD, BLACK, BOLD_GRAY, WHITE, BOLD_WHITE,
# GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE, BOLD_BLUE, PINK, CYAN, BOLD_CYAN
# RED, BOLD_RED, WARN_RED, CRIT_RED, DANGER_RED,
# Set to a null string "" if you do not want color.
# Current working directory
LP_COLOR_PATH="$BOLD_WHITE" # as normal user
LP_COLOR_PATH_ROOT="$BOLD_YELLOW" # as root
# Color of the proxy mark
LP_COLOR_PROXY="$BOLD_BLUE"
# Jobs count
LP_COLOR_JOB_D="$YELLOW" # Detached (aka screen sessions)
LP_COLOR_JOB_R="$BOLD_YELLOW" # Running (xterm &)
LP_COLOR_JOB_Z="$BOLD_YELLOW" # Sleeping (Ctrl-Z)
# Last error code
LP_COLOR_ERR="$PURPLE"
# Prompt mark
LP_COLOR_MARK="$BOLD_WHITE" # as user
LP_COLOR_MARK_ROOT="$BOLD_RED" # as root
# Current user
LP_COLOR_USER_LOGGED="" # user who logged in
LP_COLOR_USER_ALT="$BOLD" # user but not the one who logged in
LP_COLOR_USER_ROOT="$BOLD_YELLOW" # root
# Hostname
LP_COLOR_HOST="" # local host
LP_COLOR_SSH="$BOLD_CYAN" # connected via SSH
LP_COLOR_TELNET="$WARN_RED" # connected via telnet
# Separation mark (aka permiison in the working dir)
LP_COLOR_WRITE="$GREEN" # have write permission
LP_COLOR_NOWRITE="$RED" # do not have write permission
# VCS
LP_COLOR_UP="$GREEN" # repository is up to date / a push have been made
LP_COLOR_COMMITS="$YELLOW" # some commits have not been pushed
LP_COLOR_CHANGES="$RED" # there is some changes to commit
LP_COLOR_DIFF="$PURPLE" # number of lines impacted by current changes
# Battery
LP_COLOR_CHARGING_ABOVE="$GREEN" # charging and above threshold
LP_COLOR_CHARGING_UNDER="$YELLOW" # charging but under threshold
LP_COLOR_DISCHARGING_ABOVE="$YELLOW" # discharging but above threshold
LP_COLOR_DISCHARGING_UNDER="$RED" # discharging and under threshold
# Color maps (battery and load levels)
# Range from 0 (nothing special) to 9 (alert)
LP_COLORMAP_0=""
LP_COLORMAP_1="$GREEN"
LP_COLORMAP_2="$BOLD_GREEN"
LP_COLORMAP_3="$YELLOW"
LP_COLORMAP_4="$BOLD_YELLOW"
LP_COLORMAP_5="$RED"
LP_COLORMAP_6="$BOLD_RED"
LP_COLORMAP_7="$WARN_RED"
LP_COLORMAP_8="$CRIT_RED"
LP_COLORMAP_9="$DANGER_RED"
# vim: set ts=4 sw=4 tw=120 ft=sh: