diff --git a/README.md b/README.md index ba6a05a..c832e9d 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,43 @@ To erase your new formatting, just bring the `LP_PS1` to a null string: export LP_PS1="" +## COLOR THEMES + +You can change the colors of some part of the liquid prompt by changing the +following parameters in the config file. + +Available colors are: +BOLD, BLACK, BOLD_GRAY, WHITE, BOLD_WHITE, RED, BOLD_RED, WARN_RED, CRIT_RED, +GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE, BOLD_BLUE, PINK, CYAN, BOLD_CYAN. +Set to a null string "" if you do not want color. + +* Current working directory + * `LP_COLOR_PATH` as normal user + * `LP_COLOR_PATH_ROOT` as root +* Color of the proxy mark + * `LP_COLOR_PROXY` +* Jobs count + * `LP_COLOR_JOB_D` Detached (aka screen sessions) + * `LP_COLOR_JOB_R` Running (xterm &) + * `LP_COLOR_JOB_Z` Sleeping (Ctrl-Z) +* Last error code + * `LP_COLOR_ERR` +* Prompt mark + * `LP_COLOR_MARK` as user + * `LP_COLOR_MARK_ROOT` as root +* Current user + * `LP_COLOR_USER_LOGGED` user who logged in + * `LP_COLOR_USER_ALT` user but not the one who logged in + * `LP_COLOR_USER_ROOT` root +* Hostname + * `LP_COLOR_HOST` local host + * `LP_COLOR_SSH` connected via SSH + * `LP_COLOR_TELNET` connected via telnet +* Separation mark (aka permiison in the working dir) + * `LP_COLOR_WRITE` have write permission + * `LP_COLOR_NOWRITE` do not have write permission + + ## KNOWN LIMITATIONS AND BUGS Liquid prompt is distributed under the GNU Affero General Public License diff --git a/liquidprompt b/liquidprompt index 926e484..825e63a 100755 --- a/liquidprompt +++ b/liquidprompt @@ -253,7 +253,7 @@ _lp_source_config # Who are we? # ############### -# Yellow for root, light grey if the user is not the login one, else no color. +# Yellow for root, bold if the user is not the login one, else no color. _lp_user() { local user @@ -261,12 +261,12 @@ _lp_user() if [[ "$EUID" -ne "0" ]] ; then # if user is not login user if [[ ${USER} != "$(logname 2>/dev/null)" ]]; then - user="${BOLD}${_LP_USER_SYMBOL}${NO_COL}" + user="${LP_COLOR_USER_ALT}${_LP_USER_SYMBOL}${NO_COL}" else - user="${_LP_USER_SYMBOL}" + user="${LP_COLOR_USER_LOGGED}${_LP_USER_SYMBOL}${NO_COL}" fi else - user="${BOLD_YELLOW}${_LP_USER_SYMBOL}${NO_COL}" + user="${LP_COLOR_USER_ROOT}${_LP_USER_SYMBOL}${NO_COL}" fi echo -ne $user @@ -326,14 +326,14 @@ _lp_host_color() if [[ $LP_HOSTNAME_ALWAYS == 0 ]] ; then ret="${ret}" # no hostname if local else - ret="${ret}@${_LP_HOST_SYMBOL}" + ret="${ret}@${LP_COLOR_HOST}${_LP_HOST_SYMBOL}" fi elif [[ "$conn" == "ssh" ]] ; then - ret="${ret}@${BOLD_CYAN}${_LP_HOST_SYMBOL}" + ret="${ret}@${LP_COLOR_SSH}${_LP_HOST_SYMBOL}" elif [[ "$conn" == "tel" ]] ; then - ret="${ret}@${WARN_RED}${_LP_HOST_SYMBOL}" + ret="${ret}@${LP_COLOR_TELNET}${_LP_HOST_SYMBOL}" else - ret="${ret}@${_LP_HOST_SYMBOL}" + ret="${ret}@${_LP_HOST_SYMBOL}" # defaults to no color fi echo -ne "${ret}${NO_COL}" @@ -453,9 +453,9 @@ _lp_shorten_path() _lp_permissions_color() { if [[ -w "${PWD}" ]]; then - echo "${GREEN}:${NO_COL}" + echo "${LP_COLOR_WRITE}:${NO_COL}" else - echo "${RED}:${NO_COL}" + echo "${LP_COLOR_NOWRITE}:${NO_COL}" fi } @@ -479,31 +479,31 @@ _lp_jobcount_color() # d/&/z if [[ $screens != "0" && $running != "0" && $stopped != "0" ]] ; then - rep="${NO_COL}${YELLOW}${screens}${m_detached}${NO_COL}/${YELLOW}${running}${m_run}${NO_COL}/${BOLD_YELLOW}${stopped}${m_stop}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_D}${screens}${m_detached}${NO_COL}/${LP_COLOR_JOB_R}${running}${m_run}${NO_COL}/${LP_COLOR_JOB_Z}${stopped}${m_stop}${NO_COL}" # _/&/_ elif [[ $screens == "0" && $running != "0" && $stopped == "0" ]] ; then - rep="${NO_COL}${YELLOW}${running}${m_run}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_R}${running}${m_run}${NO_COL}" # _/_/z elif [[ $screens == "0" && $running == "0" && $stopped != "0" ]] ; then - rep="${NO_COL}${BOLD_YELLOW}${stopped}${m_stop}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_Z}${stopped}${m_stop}${NO_COL}" # d/_/_ elif [[ $screens != "0" && $running == "0" && $stopped == "0" ]] ; then - rep="${NO_COL}${YELLOW}${screens}${m_detached}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_D}${screens}${m_detached}${NO_COL}" # d/&/_ elif [[ $screens != "0" && $running != "0" && $stopped == "0" ]] ; then - rep="${NO_COL}${YELLOW}${screens}${m_detached}${NO_COL}/${YELLOW}${running}${m_run}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_D}${screens}${m_detached}${NO_COL}/${LP_COLOR_JOB_R}${running}${m_run}${NO_COL}" # d/_/z elif [[ $screens != "0" && $running == "0" && $stopped != "0" ]] ; then - rep="${NO_COL}${YELLOW}${screens}${m_detached}${NO_COL}/${BOLD_YELLOW}${stopped}${m_stop}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_D}${screens}${m_detached}${NO_COL}/${LP_COLOR_JOB_Z}${stopped}${m_stop}${NO_COL}" # _/&/z elif [[ $screens == "0" && $running != "0" && $stopped != "0" ]] ; then - rep="${NO_COL}${YELLOW}${running}${m_run}${NO_COL}/${BOLD_YELLOW}${stopped}${m_stop}${NO_COL}" + rep="${NO_COL}${LP_COLOR_JOB_R}${running}${m_run}${NO_COL}/${LP_COLOR_JOB_Z}${stopped}${m_stop}${NO_COL}" fi echo -ne "$rep" } @@ -829,9 +829,9 @@ _lp_load_color() _lp_smart_mark() { local COL - COL=${BOLD} + COL=${LP_COLOR_MARK} if [[ "$EUID" -eq "0" ]] ; then - COL=${BOLD_RED} + COL=${LP_COLOR_MARK_ROOT} fi local mark @@ -916,16 +916,16 @@ _lp_set_bash_prompt() if [[ "$EUID" -ne "0" ]] then # path in foreground color - PS1="${PS1}${BOLD}${LP_PWD}${NO_COL}]${LP_PROXY}" + PS1="${PS1}${LP_COLOR_PATH}${LP_PWD}${NO_COL}]${LP_COLOR_PROXY}${LP_PROXY}${NO_COL}" # add VCS infos PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}" else # path in yellow - PS1="${PS1}${YELLOW}${LP_PWD}${NO_COL}]${LP_PROXY}" + PS1="${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 - PS1="${PS1}${PURPLE}${LP_RET}${NO_COL}${LP_MARK}" + PS1="${PS1}${LP_COLOR_ERR}${LP_RET}${NO_COL}${LP_MARK}" # Glue the bash prompt always go to the first column. # Avoid glitches after interrupting a command with Ctrl-C diff --git a/liquidpromptrc-dist b/liquidpromptrc-dist index 2173a91..b761f65 100644 --- a/liquidpromptrc-dist +++ b/liquidpromptrc-dist @@ -3,6 +3,10 @@ # LIQUID PROMPT CONFIGURATION FILE # #################################### +############# +# BEHAVIOUR # +############# + # Maximal value under which the battery level is displayed # Recommended value is 75 LP_BATTERY_THRESHOLD=75 @@ -24,16 +28,27 @@ LP_PATH_KEEP=2 # set to 1 if you want to always see the hostname LP_HOSTNAME_ALWAYS=0 -# If charset is UTF-8 + +########## +# 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 - LP_BATTERY_MARK="⌁" - LP_ADAPTER_MARK="⏚" - LP_LOAD_MARK="⌂" - LP_PROXY_MARK="↥" - LP_GIT_MARK="±" - LP_MERCURIAL_MARK="☿" - LP_SUBVERSION_MARK="‡" + # 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" @@ -43,4 +58,43 @@ else LP_SUBVERSION_MARK="=" fi +# Colors +# Available colors are: +# BOLD, BLACK, BOLD_GRAY, WHITE, BOLD_WHITE, RED, BOLD_RED, WARN_RED, CRIT_RED, +# GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE, BOLD_BLUE, PINK, CYAN, BOLD_CYAN +# 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 + # vim: set ts=4 sw=4 tw=120 ft=sh: