manual merge
This commit is contained in:
commit
819c2c5ae2
28
README.md
28
README.md
@ -56,14 +56,15 @@ preserving the first two directories;
|
||||
* the current Python virtual environment, if any;
|
||||
* an up arrow if an HTTP proxy is in use;
|
||||
* the name of the current branch if you are in a version control repository
|
||||
(git, mercurial or subversion), in green if everything is up to date, in red if
|
||||
there is changes, in yellow if there is pending commits to push;
|
||||
* the number of added/deleted lines, if changes have been made and the number
|
||||
of pending commits, if any;
|
||||
(git, mercurial, subversion or fossil), in green if everything is up
|
||||
to date, in red if there is changes, in yellow if there is pending
|
||||
commits to push;
|
||||
* the number of added/deleted lines (git) or files (fossil), if
|
||||
changes have been made and the number of pending commits, if any;
|
||||
* a star if there is some untracked files in the repository;
|
||||
* the error code of the last command, if it has failed in some way;
|
||||
* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, $ for simple
|
||||
user, a red # for root.
|
||||
* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, ⌘
|
||||
for fossil, $ for simple user, a red # for root.
|
||||
* if you ask for, the liquidprompt will be replicated in your terminal window's
|
||||
title (without the colors)
|
||||
|
||||
@ -126,6 +127,7 @@ building:
|
||||
* `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
|
||||
* `LP_ENABLE_FOSSIL`, if you want to have fossil informations
|
||||
* `LP_ENABLE_VCS_ROOT`, if you want to show VCS informations with root account
|
||||
* `LP_ENABLE_TITLE`, if you want to use the prompt as your terminal window's title
|
||||
|
||||
@ -135,6 +137,13 @@ Note also that all the `LP_ENABLE_…` variables override the templates,
|
||||
i.e. 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.
|
||||
|
||||
If you are using bash and want to use the `PROMPT_DIRTRIM` built-in
|
||||
functionality to shorten but still have liquidprompt calculating the number of
|
||||
directories to keep in the path, precise a value for `PROMPT_DIRTRIM` before
|
||||
sourcing liquidprompt and liquidprompt will override this value with one
|
||||
fitting the width of your terminal.
|
||||
|
||||
|
||||
## CUSTOMIZING THE PROMPT
|
||||
|
||||
### ADD A PS1 PREFIX
|
||||
@ -164,6 +173,7 @@ Available features:
|
||||
* `LP_GIT` git
|
||||
* `LP_HG` mercurial
|
||||
* `LP_SVN` subversion
|
||||
* `LP_FOSSIL` fossil
|
||||
* `LP_ERR` last error code
|
||||
* `LP_MARK` prompt mark
|
||||
* `LP_TITLE` the prompt as a window's title escaped sequence
|
||||
@ -226,7 +236,7 @@ Set to a null string "" if you do not want color.
|
||||
* `LP_COLOR_UP` repository is up to date / a push have been made
|
||||
* `LP_COLOR_COMMITS` some commits have not been pushed
|
||||
* `LP_COLOR_CHANGES` there is some changes to commit
|
||||
* `LP_COLOR_DIFF` number of lines impacted by current changes
|
||||
* `LP_COLOR_DIFF` number of lines or files impacted by current changes
|
||||
* Battery
|
||||
* `LP_COLOR_CHARGING_ABOVE` charging and above threshold
|
||||
* `LP_COLOR_CHARGING_UNDER` charging but under threshold
|
||||
@ -244,6 +254,7 @@ Special characters:
|
||||
* `LP_MARK_HG` (default: "☿") prompt mark in hg repositories
|
||||
* `LP_MARK_SVN` (default: "‡") prompt mark in svn repositories
|
||||
* `LP_MARK_GIT` (default: "±") prompt mark in git repositories
|
||||
* `LP_MARK_FOSSIL` (default: "⌘") prompt mark in fossil repositories
|
||||
* `LP_MARK_UNTRACKED` (default: "*") if git has untracked files
|
||||
* `LP_TITLE_OPEN` (default: "\e]0;") escape character opening a window's title
|
||||
* `LP_TITLE_CLOSE` (default: "\a") escape character closing a window's title
|
||||
@ -261,6 +272,9 @@ the display of the liquid prompt.
|
||||
* Subversion repository cannot display commits to be pushed, this is a
|
||||
limitation of the Subversion versionning model.
|
||||
* The proxy detection only uses the `$http_proxy` environment variable.
|
||||
<<<<<<< HEAD
|
||||
* The window's title escape sequence may not work properly on some terminals
|
||||
(like xterm-256)
|
||||
|
||||
=======
|
||||
>>>>>>> 3aedf713f42fcfa91a1eba5cd4b4dbc36a59ee58
|
||||
|
@ -34,13 +34,13 @@ then
|
||||
# path in foreground color
|
||||
LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
|
||||
# add VCS infos
|
||||
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}"
|
||||
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
|
||||
else
|
||||
# path in yellow
|
||||
LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
|
||||
# do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT)
|
||||
[[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && \
|
||||
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}"
|
||||
LP_PS1="${LP_PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
|
||||
fi
|
||||
# add return code and prompt mark
|
||||
LP_PS1="${LP_PS1}${LP_ERR}${LP_MARK}"
|
||||
|
@ -17,6 +17,7 @@ if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]
|
||||
LP_MARK_HG="☿" # prompt mark in hg repositories
|
||||
LP_MARK_SVN="‡" # prompt mark in svn repositories
|
||||
LP_MARK_GIT="±" # prompt mark in git repositories
|
||||
LP_MARK_FOSSIL="⌘" # prompt mark in fossil repositories
|
||||
LP_MARK_UNTRACKED="*" # if git has untracked files
|
||||
else
|
||||
# If charset is anything else, fallback to ASCII chars
|
||||
@ -27,6 +28,7 @@ else
|
||||
LP_MARK_HG="m"
|
||||
LP_MARK_SVN="="
|
||||
LP_MARK_GIT="+"
|
||||
LP_MARK_FOSSIL="f"
|
||||
LP_MARK_UNTRACKED="*"
|
||||
fi
|
||||
|
||||
|
158
liquidprompt
158
liquidprompt
@ -29,7 +29,7 @@
|
||||
# Joris Dedieu <joris@pontiac3.nfrance.com> # Portability framework, FreeBSD support, bugfixes.
|
||||
# Ludovic Rousseau <ludovic.rousseau@gmail.com> # Lot of bugfixes.
|
||||
# Yann 'Ze' Richard <ze@nbox.org> # Do not fail on missing commands.
|
||||
# François Schmidts <fschmidts@olfeo.com> # Simpler SSH_IP acquiring method.
|
||||
# François Schmidts <francois.schmidts@gmail.com> # small code fix, _lp_get_dirtrim
|
||||
# Thomas Debesse <thomas.debesse@gmail.com> # Fix columns use.
|
||||
# Florian Le Frioux <florian@lefrioux.fr> # Use ± mark when root in VCS dir.
|
||||
# Luc Didry <luc@fiat-tux.fr> # Zsh port
|
||||
@ -202,6 +202,7 @@ _lp_source_config()
|
||||
LP_ENABLE_BATT=${LP_ENABLE_BATT:-1}
|
||||
LP_ENABLE_GIT=${LP_ENABLE_GIT:-1}
|
||||
LP_ENABLE_SVN=${LP_ENABLE_SVN:-1}
|
||||
LP_ENABLE_FOSSIL=${LP_ENABLE_FOSSIL:-1}
|
||||
LP_ENABLE_HG=${LP_ENABLE_HG:-1}
|
||||
LP_ENABLE_TIME=${LP_ENABLE_TIME:-0}
|
||||
LP_ENABLE_VIRTUALENV=${LP_ENABLE_VIRTUALENV:-1}
|
||||
@ -215,6 +216,7 @@ _lp_source_config()
|
||||
LP_MARK_HG=${LP_MARK_HG:-"☿"}
|
||||
LP_MARK_SVN=${LP_MARK_SVN:-"‡"}
|
||||
LP_MARK_GIT=${LP_MARK_GIT:-"±"}
|
||||
LP_MARK_FOSSIL=${LP_MARK_FOSSIL:-"⌘"}
|
||||
LP_MARK_UNTRACKED=${LP_MARK_UNTRACKED:-"*"}
|
||||
|
||||
LP_COLOR_PATH=${LP_COLOR_PATH:-$BOLD_WHITE}
|
||||
@ -287,6 +289,7 @@ unset _lp_source_config
|
||||
# Disable features if the tool is not installed
|
||||
[[ "$LP_ENABLE_GIT" = 1 ]] && { command -v git >/dev/null || LP_ENABLE_GIT=0 ; }
|
||||
[[ "$LP_ENABLE_SVN" = 1 ]] && { command -v svn >/dev/null || LP_ENABLE_SVN=0 ; }
|
||||
[[ "$LP_ENABLE_FOSSIL" = 1 ]] && { command -v fossil >/dev/null || LP_ENABLE_FOSSIL=0 ; }
|
||||
[[ "$LP_ENABLE_HG" = 1 ]] && { command -v hg >/dev/null || LP_ENABLE_HG=0 ; }
|
||||
[[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; }
|
||||
|
||||
@ -345,11 +348,16 @@ _lp_connection()
|
||||
# The connection is not expected to change from inside the shell, so we
|
||||
# build this just once
|
||||
LP_HOST=""
|
||||
if [[ -r /etc/debian_chroot ]] ; then
|
||||
_chroot()
|
||||
{
|
||||
if [[ -r /etc/debian_chroot ]] ; then
|
||||
local debchroot
|
||||
debchroot=$(cat /etc/debian_chroot)
|
||||
LP_HOST="${LP_HOST}(${debchroot})"
|
||||
fi
|
||||
echo "(${debchroot})"
|
||||
fi
|
||||
}
|
||||
LP_HOST="$(_chroot)"
|
||||
unset _chroot
|
||||
|
||||
# If we are connected with a X11 support
|
||||
if [[ -n "$DISPLAY" ]] ; then
|
||||
@ -406,8 +414,12 @@ _lp_proxy()
|
||||
# + keep some left part of the path if asked
|
||||
_lp_shorten_path()
|
||||
{
|
||||
if [[ "$LP_ENABLE_SHORTEN_PATH" != 1 ]] ; then
|
||||
echo "$1"
|
||||
if [[ "$LP_ENABLE_SHORTEN_PATH" != 1 || -n "$PROMPT_DIRTRIM" ]] ; then
|
||||
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
|
||||
echo "\\w"
|
||||
else
|
||||
echo "$(print -P "%~")"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
# the character that will replace the part of the path that is masked
|
||||
@ -418,17 +430,10 @@ _lp_shorten_path()
|
||||
keep=$LP_PATH_KEEP
|
||||
fi
|
||||
|
||||
local len_percent=$2
|
||||
|
||||
local p
|
||||
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
|
||||
p=$(echo "$1" | sed -e "s|$HOME|~|")
|
||||
elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then
|
||||
p=$1
|
||||
fi
|
||||
local p="${PWD/$HOME/~}"
|
||||
local len="${#p}"
|
||||
|
||||
local max_len=$((${COLUMNS:-80}*$len_percent/100))
|
||||
local max_len=$((${COLUMNS:-80}*$LP_PATH_LENGTH/100))
|
||||
local mask_len="${#mask}"
|
||||
local slashes=0
|
||||
|
||||
@ -501,6 +506,31 @@ _lp_shorten_path()
|
||||
fi
|
||||
}
|
||||
|
||||
# In bash shell, PROMPT_DIRTRIM is the number of directory to keep at the end
|
||||
# of the displayed path (if "\w" is present in the PS1 var).
|
||||
# liquidprompt can calculate this number under two condition, path shortening
|
||||
# must be activated and PROMPT_DIRTRIM must be already set.
|
||||
_lp_get_dirtrim() {
|
||||
[[ "$LP_ENABLE_SHORTEN_PATH" != 1 ]] && echo 0 && return
|
||||
|
||||
local p="${PWD/$HOME/~}"
|
||||
local len=${#p}
|
||||
local max_len=$((${COLUMNS:-80}*$LP_PATH_LENGTH/100))
|
||||
local PROMPT_DIRTRIM=0
|
||||
|
||||
if [[ "$((len))" -gt "$((max_len))" ]]; then
|
||||
local i
|
||||
|
||||
for ((i=$len;i>=0;i--))
|
||||
do
|
||||
[[ $(($len-$i)) -gt $max_len ]] && break
|
||||
[[ "${p:i:1}" == "/" ]] && PROMPT_DIRTRIM=$((PROMPT_DIRTRIM+1))
|
||||
done
|
||||
[[ "$((PROMPT_DIRTRIM))" -eq 0 ]] && PROMPT_DIRTRIM=1
|
||||
fi
|
||||
echo "$PROMPT_DIRTRIM"
|
||||
}
|
||||
|
||||
# Display a ":"
|
||||
# colored in green if user have write permission on the current directory
|
||||
# colored in red if it have not.
|
||||
@ -739,6 +769,90 @@ _lp_svn_branch_color()
|
||||
}
|
||||
|
||||
|
||||
# FOSSIL #
|
||||
|
||||
# Get the tag name of the current directory
|
||||
_lp_fossil_branch()
|
||||
{
|
||||
[[ "$LP_ENABLE_FOSSIL" != 1 ]] && return
|
||||
|
||||
local branch
|
||||
branch=$(fossil status 2>/dev/null | grep tags: | cut -c17-)
|
||||
if [[ -n "$branch" ]] ; then
|
||||
echo "$branch"
|
||||
else
|
||||
if fossil info &>/dev/null ; then
|
||||
echo "no-tag"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Set a color depending on the branch state:
|
||||
# - green if the repository is clean
|
||||
# - red if there is changes to commit
|
||||
# - yellow if the branch has no tag name
|
||||
#
|
||||
# Add the number of impacted files with a
|
||||
# + when files are ADDED or EDITED
|
||||
# - when files are DELETED
|
||||
_lp_fossil_branch_color()
|
||||
{
|
||||
[[ "$LP_ENABLE_FOSSIL" != 1 ]] && return
|
||||
|
||||
local branch
|
||||
branch=$(_lp_fossil_branch)
|
||||
|
||||
if [[ ! -z "$branch" ]] ; then
|
||||
local C2E # Modified files (added or edited)
|
||||
local C2D # Deleted files
|
||||
local C2A # Extras files
|
||||
local ret
|
||||
C2E=$(fossil changes | wc -l)
|
||||
C2D=$(fossil changes | grep DELETED | wc -l)
|
||||
let "C2E = $C2E - $C2D"
|
||||
C2A=$(fossil extras | wc -l)
|
||||
ret=""
|
||||
|
||||
if [[ "$C2E" -gt 0 ]] ; then
|
||||
ret+="+$C2E"
|
||||
fi
|
||||
|
||||
if [[ "$C2D" -gt 0 ]] ; then
|
||||
if [[ "$ret" = "" ]] ; then
|
||||
ret+="-$C2D"
|
||||
else
|
||||
ret+="/-$C2D"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$C2A" -gt 0 ]] ; then
|
||||
C2A="$LP_MARK_UNTRACKED"
|
||||
else
|
||||
C2A=""
|
||||
fi
|
||||
|
||||
if [[ "$ret" != "" ]] ; then
|
||||
ret="(${LP_COLOR_DIFF}$ret${NO_COL})"
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$branch" = "no-tag" ]] ; then
|
||||
# Warning, your branch has no tag name !
|
||||
branch="${LP_COLOR_COMMITS}$branch${NO_COL}$ret${LP_COLOR_COMMITS}$C2A${NO_COL}"
|
||||
else
|
||||
if [[ "$C2E" -eq 0 && "$C2D" -eq 0 ]] ; then
|
||||
# All is up-to-date
|
||||
branch="${LP_COLOR_UP}$branch$C2A${NO_COL}"
|
||||
else
|
||||
# There're some changes to commit
|
||||
branch="${LP_COLOR_CHANGES}$branch${NO_COL}$ret${LP_COLOR_CHANGES}$C2A${NO_COL}"
|
||||
fi
|
||||
fi
|
||||
echo -ne "$branch"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
##################
|
||||
# Battery status #
|
||||
##################
|
||||
@ -974,6 +1088,8 @@ _lp_smart_mark()
|
||||
mark=$LP_MARK_HG
|
||||
elif [[ ! -z $(_lp_svn_branch) ]] ; then
|
||||
mark=$LP_MARK_SVN
|
||||
elif [[ ! -z $(_lp_fossil_branch) ]] ; then
|
||||
mark=$LP_MARK_FOSSIL
|
||||
fi
|
||||
echo -ne "${COL}${mark}${NO_COL}"
|
||||
}
|
||||
@ -1035,11 +1151,8 @@ _lp_set_prompt()
|
||||
LP_USER=$(_lp_user)
|
||||
# LP_HOST is a global set at load time
|
||||
LP_PERM=$(_lp_permissions_color)
|
||||
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
|
||||
LP_PWD=$(_lp_shorten_path "$PWD" $LP_PATH_LENGTH)
|
||||
elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then
|
||||
LP_PWD=$(_lp_shorten_path "$(print -P "%~")" $LP_PATH_LENGTH)
|
||||
fi
|
||||
LP_PWD=$(_lp_shorten_path)
|
||||
[[ -n "$PROMPT_DIRTRIM" ]] && PROMPT_DIRTRIM=$(_lp_get_dirtrim)
|
||||
LP_PROXY="${LP_COLOR_PROXY}$(_lp_proxy)${NO_COL}"
|
||||
|
||||
# right of main prompt: space at left
|
||||
@ -1048,6 +1161,7 @@ _lp_set_prompt()
|
||||
LP_GIT=$(_lp_sl "$(_lp_git_branch_color)")
|
||||
LP_HG=$(_lp_sl "$(_lp_hg_branch_color)")
|
||||
LP_SVN=$(_lp_sl "$(_lp_svn_branch_color)")
|
||||
LP_FOSSIL=$(_lp_sl "$(_lp_fossil_branch_color)")
|
||||
fi
|
||||
|
||||
# end of the prompt line: double spaces
|
||||
@ -1072,13 +1186,13 @@ _lp_set_prompt()
|
||||
# path in foreground color
|
||||
PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
|
||||
# add VCS infos
|
||||
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}"
|
||||
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
|
||||
else
|
||||
# path in yellow
|
||||
PS1="${PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
|
||||
# do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT)
|
||||
[[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && \
|
||||
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}"
|
||||
PS1="${PS1}${LP_GIT}${LP_HG}${LP_SVN}${LP_FOSSIL}"
|
||||
fi
|
||||
# add return code and prompt mark
|
||||
PS1="${PS1}${LP_ERR}${LP_MARK}"
|
||||
|
@ -78,6 +78,10 @@ LP_ENABLE_SVN=1
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_HG=1
|
||||
|
||||
# Do you want to use the fossil special features ?
|
||||
# Recommended value is 1
|
||||
LP_ENABLE_FOSSIL=1
|
||||
|
||||
# Show time of the last prompt display
|
||||
# Recommended value is 0
|
||||
LP_ENABLE_TIME=0
|
||||
|
Loading…
Reference in New Issue
Block a user