Added latest code

This commit is contained in:
Austen Adler 2016-07-18 16:22:07 -04:00
parent 3468d0e8af
commit e336cd2528
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1
15 changed files with 1016 additions and 619 deletions

146
CHANGES
View File

@ -1,15 +1,123 @@
1.11 ????-??-??
Bug fixes:
- OS X: sudo feature fixed
- OS X: battery level restored
1.9 2014-11-?? dolmen (Olivier Mengué)
1.10 2016-05-30
Breaking changes:
- In themes, LP_COLORMAP_x variables are replaced by a single
LP_COLORMAP array variable. A warning will be displayed at startup
if your config still uses the old variables, but a compatibility
shim is active (will be removed in next release).
- Many LP_ENABLE_* settings are now static (their effect applies when
liquidprompt is loaded, and changing them at the prompt does nothing)
to more and more improve speed.
- zsh: option 'nopromptsubst' is enabled for security reasons.
This will unfortunately also affect evaluations of other prompt
contexts such as RPS1.
- Variables LP_SCREEN_TITLE_OPEN and LP_SCREEN_TITLE_CLOSE are now
removed to simplify the code (GitHub #371)
New features:
- Sudo:
* The color of the prompt mark is now dynamic and changes to
LP_COLOR_MARK_SUDO (default: bold red) as long as your sudo
credentials are cached (GitHub #335).
Requires sudo 1.7.0+.
This feature must be enabled with LP_ENABLE_SUDO=1
Use 'sudo -K' to revoke your credentials early.
* This feature is disabled by default as there is no way to
detect if the user has sudo rights without triggering a security
alert that will annoy the sysadmin.
- Git:
* Show the number of commits behind the remote (GitHub #269)
* Show the rebasing/merging/cherry-picking state (GitHub #409)
- Add variable LP_TTYN: the basename of the terminal (GitHub #357)
- Add setting LP_ENABLE_FQDN to show the fully qualified domain name
of the host (GitHub #254, #277)
- LP_HOSTNAME_ALWAYS=-1 to always hide the hostname (GitHub #406)
- Run duration of the last command (LP_ENABLE_RUNTIME) is now also
supported on zsh (GitHub #404, #355)
- Python: add support for Conda (CONDA_DEFAULT_ENV) (GitHub #425)
Bug fixes:
- Use $XDG_CONFIG_HOME to locate the config (GitHub #415, #420, #425)
- Improved zsh integration (but most issues had no impact of the
user experience)
- Fix escaping of special chars from $PWD (well, almost, see GitHub
#389) and explicitely set the shell options we need (instead of
relying on the shell default settings)
- Git:
* Fix typo in git work directory detection
- Fossil:
* Fix on darwin (GitHub #390)
- LP_DISABLED_VCS_PATH is fixed on zsh (GitHub #423)
- Battery indicator:
* MacOS: many fixes to handle (all?) edge cases (GitHub #326)
We now have a pmset simulator to better detect regressions.
- Temperature indicator:
* The code using the 'sensors' command now uses the '-u' option
("raw output") that is easier to parse. This format is at least
7 years old. (GitHub #379, #380)
* We now try each backend (acpi/sensors) once to check it works
at startup and disable the feature if none works.
(GitHub #410, #319, #381, #387)
- CPU load indicator:
* Fix the scale that was incorrectly 0-200 (GitHub #391)
- Title:
* Fix terminal sequences that were sent in the title text (the
escaping algorithm is rewritten and now just correct).
- Terminal channel:
* Fix detection of tmux (GitHub #304, #377)
* Fix detection of local session on OS X (GitHub #407)
- Misc:
* Fix bash 3 compatibility (GitHub #313)
* Clear GREP_OPTIONS and skip 'grep' aliases (GitHub #372)
- Shortened path:
* Fix bugs when $PWD contains spaces or special chars (GitHub #369)
* Optimize implementation in case of LP_PATH_KEEP=-1 : LP_PWD
becomes static (related to GitHub #256, #336)
* Optimize implementation in case LP_ENABLE_SHORTEN_PATH=0
* Optimize implementation in case LP_ENABLE_SHORTEN_PATH=0 on bash
with PROMPT_DIRTRIM
- Sample configuration files:
* example.bashrc: major fixes
- The last statement of liquidprompt did not return 0 (GitHub #360,#361)
- Analog clock:
* complete rewrite for speed and correctness (GitHub #365 and other
issues)
- Documentation:
* Many small fixes
- Move dist/ to contrib/dist/ as files there are unmaintained
- Fix title escapes in zsh inside tmux/screen (GitHub #370, #371)
Thanks to Matt Fletcher (@MaffooBristol), Kevin Yap (@iKevinY), Sean
Hussey (@seanhussey), François Schmidts (@jaesivsm), Morgan Knicely
(@morganizeit), Daniel Serodio (@dserodio), Jonathan Giddy
(@jongiddy), Jeremy Clement (@jeremyclement), Panayiotis Kkolos
(@pkkolos), Arturo Borrero Gonzalez (@aborrero), Samuel Krieg
(@SamK), Brian May (@brianmay), Colin Lieberman (@colinlieberman),
@hegedus, Anthony Gelibert (@anthonygelibert), Anthony Ramine (@nox),
Erik M Jacobs (@thoraxe), Pedro Parracho (@berserck), Brad Beyenhof
(@augmentedfourth), Austen Adler (@stonewareslord), Hagen Graf
(@hcgraf), William P. Riley-Land (@wprl), Dave Rigby (@daverigby),
Ned Batchelder (@nedbat), Fabien Marty (@thefab), Alessio Garzi
(@Ozzyboshi), Roger Huang (@rhuang2014), Sebastian Bremicker
(@sebrem), Alex Prengere (@alexprengere), Philipp Grogg (@gro-gg),
Tener Hades (@tenerhades), Thomas Kühnel (@kuehnelth), Étienne Deparis
(@milouse), @Hotschke, Software Mechanic (@softwaremechanic), Simon
McVittie (@smcv)...
... for their patches or bug reports.
1.9 2014-11-12 dolmen (Olivier Mengué)
Bug fixes:
- Battery indicator:
* General fixes (Github #264)
* MacOS: fix for computers without battery (like iMacs) (Github
* General fixes (GitHub #264)
* MacOS: fix for computers without battery (like iMacs) (GitHub
#319)
* Optimize colormap
- Temperature indicator:
* Linux: Add a guard against any future l10n of the 'acpi' command
* Linux: Fix for negative temperature values (Github #308)
* Linux: Fix for negative temperature values (GitHub #308)
- CPU load:
* Darwin/BSD: quoting fixes
- Hostname:
@ -17,41 +125,41 @@
* Simplify chroot detection
- VCS:
- Git:
* Use --porcelain for "git status" (Github #270)
* Minir optimization (Github #266)
* Use --porcelain for "git status" (GitHub #270)
* Minir optimization (GitHub #266)
- Fossil:
* Cleanup and fixes (Github #274 and others)
* Cleanup and fixes (GitHub #274 and others)
- Subversion:
* Fix branch/tag name extraction (Github #117, #237, #293)
* Fix branch/tag name extraction (GitHub #117, #237, #293)
- Bazar:
* Fix branch name extraction
* zsh fixes (Github #303)
* zsh fixes (GitHub #303)
- Mercurial:
* General cleanup for speed and fixes
* Disabled "hg outgoing" because it is slow (Github #217)
* Disabled "hg outgoing" because it is slow (GitHub #217)
- Shortened path:
* Bash: Fix quoting for PROMPT_DIRTRIM
- Prompt mark:
* Simplify implementation of LP_MARK_DEFAULT
- Jobs:
* Refactoring
* Fix when screen/tmux are not installed (Github #304)
* Fix when screen/tmux are not installed (GitHub #304)
- Analog clock:
* Fix hour for 12AM and 12PM (Github #273)
* Fix hour for 12AM and 12PM (GitHub #273)
- Misc:
* bash: save and set 'promptvars'
* bash: workaround broken pattern substitution in bash 4.2 (Github
* bash: workaround broken pattern substitution in bash 4.2 (GitHub
#289, #294, #302)
* zsh: fix restoration of the original (pre-liquidprompt) prompt
* Fix tmux detection (Github #279)
* Save IFS (Github #267)
* Fix $TERM check (Github #291)
* Fix tmux detection (GitHub #279)
* Save IFS (GitHub #267)
* Fix $TERM check (GitHub #291)
* Various quoting fixes
* Apply some shellcheck.com suggestions
* Many, many optimizations (Github #267)
* Many, many optimizations (GitHub #267)
New features:
- Add vcsh support (Github #148, #287)
- Add support for Software Collections (Github #299, #300)
- Add vcsh support (GitHub #148, #287)
- Add support for Software Collections (GitHub #299, #300)
Thanks to Anthony Gelibert, Frédéric Mahé, Panayiotis Kkolos, Étienne
Deparis, François Schmidts, Linus Wallgren, Alexander Belaev, Bartosz

View File

@ -6,21 +6,11 @@ Contributing a patch
The public stable branch for end users is `master`.
The main branch for development is `develop`. This is on top of this branch
that you must write your patches.
Any pull request built on top of `master` instead of `develop`
is additional merge work for maintainers, and you want to avoid this if you
aim for quick integration of your work.
If you wrote your patch on the wrong branch the maintainers may choose to close
the pull request and ask you to rewrite it on top of the current `develop`.
How to do the right thing?
--------------------------
$ git clone -b develop -o upstream git://github.com/nojhan/liquidprompt.git
$ git clone -o upstream git://github.com/nojhan/liquidprompt.git
$ cd liquidprompt
# Run liquidprompt and check that your issue is still on that branch
@ -41,14 +31,14 @@ How to do the right thing?
# Check that your local repo is up to date
$ git fetch
# Rebase your work on the latest state of `develop`
$ git rebase upstream/develop
# Rebase your work on the latest state of `master`
$ git rebase upstream/master
# Push your commits
$ git push github fix/my-fix
$ git push github fix/my-feature
$ git push github feature/my-feature
# Create the pull request on GitHub. Check that Github chose the `develop`
# Create the pull request on GitHub. Check that Github chose the `master`
# branch as the starting point for your branch.
@ -75,8 +65,8 @@ How to make a good pull request?
For example use triple backquotes for code blocks.
Never, ever, merge the branches `develop` or `master` of the main repo into one
of your own branches. Instead, always rebase your own work on top the `develop`
Never, ever, merge the branches `master` of the main repo into one
of your own branches. Instead, always rebase your own work on top the `master`
branch.
How my patch will be applied?
@ -88,7 +78,7 @@ pull requests.
If your patch is accepted it will be applied either:
- by "merging" your branch
- by cherry-picking your commit on top of the `develop` branch. This makes the
- by cherry-picking your commit on top of the `master` branch. This makes the
history linear, and so easier to track.
In any case, your authorship will be preserved in the commit.
@ -101,7 +91,7 @@ between pings: 1 week, 2 weeks, then every month.
If a stable version is released while your pull request has still not been
merged on any working branch of the main repo, it would be helpful to ease
the maitainer's work by rebasing your branch on top of the latest `develop`
the maitainer's work by rebasing your branch on top of the latest `master`
and push it again to your GitHub repo. Be careful (for example create a
branch or a tag before your rebase) because your may lose all your work in
that process.

View File

@ -173,8 +173,9 @@ prompt-building process:
* `LP_ENABLE_SCREEN_TITLE`, if you want to use the prompt as your screen window's title
* `LP_ENABLE_SSH_COLORS`, if you want different colors for hosts you SSH into
* `LP_ENABLE_RUNTIME`, if you want to display the runtime of the last command
* `LP_ENABLE_SUDO`, if you want the prompt mark to change color while you have password-less root access
* `LP_ENABLE_FQDN`, if you want the display of the fully qualified domain name
* `LP_ENABLE_TIME`, if you want to display the time at which the prompt was shown
* `LP_ENABLE_OHMYGIT`, if you want to enable [Oh My Git](https://github.com/arialdomartini/oh-my-git)
* `LP_TIME_ANALOG`, if you want to show the time using an analog clock instead of numeric values
Note that if required commands are not installed, enabling the corresponding
@ -240,6 +241,7 @@ Available features:
* `LP_ERR` last error code
* `LP_MARK` prompt mark
* `LP_TITLE` the prompt as a window's title escaped sequences
* LP_TTYN the terminal basename
* `LP_BRACKET_OPEN` and `LP_BRACKET_CLOSE`, brackets enclosing the user+path part
For example, if you just want to have a prompt displaying the user and the
@ -258,7 +260,8 @@ To erase your new formatting, just bind `LP_PS1` to a null string:
## Themes
You can change the colors and special characters of some parts of Liquid Prompt
by sourcing your favorite theme file (`*.theme`) in the configuration file.
by sourcing your favorite theme file (`*.theme`) in the configuration file. See
[`liquid.theme`](liquid.theme) for an example of the default Liquid Prompt theme.
### Colors
@ -285,6 +288,7 @@ Set the variable to a null string (`""`) if you do not want color.
* Prompt mark
* `LP_COLOR_MARK` as user
* `LP_COLOR_MARK_ROOT` as root
* `LP_COLOR_MARK_SUDO` when you did `sudo` and your credentials are still cached (use `sudo -K` to revoke them)
* `LP_MARK_PREFIX="\n"` put the prompt on the second line
* Current user
* `LP_COLOR_USER_LOGGED` user who logged in
@ -332,8 +336,6 @@ Set the variable to a null string (`""`) if you do not want color.
* `LP_MARK_BRACKET_CLOSE` (default: "]") marks around the main part of the prompt
* `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
* `LP_SCREEN_TITLE_OPEN` (default: "\033k") escape character opening screen window's title
* `LP_SCREEN_TITLE_CLOSE` (default: "\033\134") escape character closing screen window's title
## Known Limitations and Bugs
@ -344,14 +346,15 @@ version 3](LICENSE).
* Does not display the number of commits to be pushed in Mercurial repositories.
* Browsing very large Subversion repositories may dramatically slow down
the display of Liquid Prompt (use `LP_DISABLED_VCS_PATH` to avoid that).
* Subversion repositories cannot display commits to be pushed; this is a
limitation of the Subversion versioning model.
* Subversion repositories cannot display commits to be pushed because
that's not how Subversion works
* The proxy detection only uses the `$http_proxy` environment variable.
* The window's title escape sequence may not work properly on some terminals
(like `xterm-256`).
* The analog clock requires a Unicode-aware terminal and at least a
sufficiently complete font on your system. The [Symbola](http://users.teilar.gr/~g1951d/)
font, designed by Georges Douros, is known to work well.
font, designed by Georges Douros, is known to work well. On Debian or Ubuntu
install try the `fonts-symbola` or `ttf-ancient-fonts` package.
## Authors

12
contrib/README Normal file
View File

@ -0,0 +1,12 @@
liquidprompt/contrib Policy
---------------------------
This directory contains files that have been contributed by contributors
but that the core liquidprompt maintainers don't take care.
So they are probably outdated, maybe of poor quality (because the maintainers
do not have the knowledge to properly review them).
So use them at your own risks, and don't fill issues about them, just send
patches.

40
contrib/dist/archlinux-aur/PKGBUILD vendored Normal file
View File

@ -0,0 +1,40 @@
# Maintainer: Julien Pecqueur (JPEC) <jpec[at]julienpecqueur[dot]net>
pkgname=liquidprompt-git
pkgver=20130314
pkgrel=3
pkgdesc="An intelligent and non intrusive prompt for bash and zsh"
url="https://github.com/nojhan/liquidprompt"
arch=('any')
license=('AGPLv3')
optdepends=('screen' 'acpi')
makedepends=('git')
md5sums=('SKIP')
install=liquidprompt.install
_gitroot="git://github.com/nojhan/liquidprompt.git"
_gitname="liquidprompt"
build() {
cd ${srcdir}/
msg "Connecting to the GIT server...."
if [[ -d ${srcdir}/${_gitname} ]] ; then
cd ${_gitname}
git reset --hard
git pull origin
msg "The local files are updated..."
else
msg "Cloning git repo..."
git clone ${_gitroot}
cd ${_gitname}
fi
git reset --hard
msg "GIT checkout done."
}
package() {
cd "${srcdir}/${_gitname}"
# install files
install -Dm755 liquidprompt "$pkgdir/usr/bin/liquidprompt"
install -Dm644 liquidpromptrc-dist "$pkgdir/etc/liquidpromptrc"
}
# vim:set ts=2 sw=2 et:

View File

@ -0,0 +1,4 @@
post_install() {
echo "Use 'source liquidprompt' to enable the prompt."
}

18
contrib/dist/debian/create_deb.sh vendored Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
echo "Creating Debian's package..."
nano ./liquidprompt/DEBIAN/control
echo "Copying files..."
cp ../../liquidprompt ./liquidprompt/usr/bin/liquidprompt
cp ../../liquidpromptrc-dist ./liquidprompt/etc/liquidpromptrc
chmod a+x ./liquidprompt/usr/bin/liquidprompt
echo "Building liquidprompt.deb..."
dpkg-deb -b liquidprompt
echo "Deleting files..."
rm -f ./liquidprompt/etc/*
rm -f ./liquidprompt/usr/bin/*
echo "Done !"

View File

@ -0,0 +1,11 @@
Package: liquidprompt
Version: 1.3-0
Section: base
Priority: optional
Architecture: all
Depends: bash
Recommends: acpi
Suggests: git, screen, tmux
Maintainer: Julien Pecqueur <jpec@julienpecqueur.net>
Description: A slick adaptative prompt for Bash and Zsh.
Homepage: http://github.com/nojhan/liquidprompt

View File

@ -8,16 +8,18 @@
# Use the system config if it exists
if [ -f /etc/bashrc ]; then
. /etc/bashrc # --> Read /etc/bashrc, if present.
elif [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc # --> Read /etc/bash.bashrc, if present.
fi
# The following lines are only for interactive shells
[[ $- = *i* ]] || return
# Use Bash completion, if installed
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# If you have your own config for Liquid Prompt, edit and uncomment this line:
# source /path/to/liquidpromptrc
# Use Liquid Prompt
source ~/.liquidprompt
source ~/liquidprompt/liquidprompt

View File

@ -17,6 +17,7 @@
# LP_ERR last error code
# LP_MARK prompt mark
# LP_TIME current time
# LP_TTYN number of current terminal (useful in title for quick switching)
# LP_RUNTIME runtime of last command
# LP_MARK_PREFIX user-defined prompt mark prefix (helpful if you want 2-line prompts)
# LP_PS1_PREFIX user-defined general-purpose prefix (default set a generic prompt as the window title)

View File

@ -73,6 +73,7 @@ LP_COLOR_ERR="$PURPLE"
# Prompt mark
LP_COLOR_MARK="$BOLD" # as user
LP_COLOR_MARK_ROOT="$BOLD_RED" # as root
LP_COLOR_MARK_SUDO="$BOLD_RED" # when sudo credentials are cached
# Current user
LP_COLOR_USER_LOGGED="" # user who logged in
@ -94,6 +95,7 @@ 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_COMMITS_BEHIND="$BOLD_RED" # 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
@ -115,17 +117,19 @@ LP_COLOR_VIRTUALENV="$CYAN"
# Runtime
LP_COLOR_RUNTIME="$YELLOW"
# Color maps (battery and load levels)
# Color map (for battery and load levels, and temperature)
# 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"
LP_COLORMAP=(
""
"$GREEN"
"$BOLD_GREEN"
"$YELLOW"
"$BOLD_YELLOW"
"$RED"
"$BOLD_RED"
"$WARN_RED"
"$CRIT_RED"
"$DANGER_RED"
)
# vim: set et sts=4 sw=4 tw=120 ft=sh:

File diff suppressed because it is too large Load Diff

View File

@ -35,8 +35,12 @@ LP_PATH_KEEP=2
# Do you want to display the hostname, even if not connected through network?
# Defaults to 0 (do not display hostname when locally connected)
# set to 1 if you want to always see the hostname
# set to -1 if you want to never see the hostname
LP_HOSTNAME_ALWAYS=0
# Use the FQDN instead of the short hostname if the hostname is displayed
LP_ENABLE_FQDN=0
# Do you want to display the user, even if the user is the same as the one logged in?
# Defaults to 1 (always display the user)
# set to 0 if you want to hide the logged user (it will always display different users)
@ -71,6 +75,11 @@ LP_ENABLE_LOAD=1
# Recommended value is 1
LP_ENABLE_BATT=1
# Do you want to use the 'sudo credentials' feature?
# Be warned that this may pollute the syslog if you don't have sudo
# credentials, and the sysadmin will hate you.
LP_ENABLE_SUDO=0
# Do you want to use VCS features with the root account?
# Recommended value is 0
LP_ENABLE_VCS_ROOT=0

48
pmset-simulator Normal file
View File

@ -0,0 +1,48 @@
# Simulator for "pmset -g batt" for testing the implementation of
# battery display on MacOS X
pmset()
{
case "$pmset_sim" in
iMac|no-battery)
# https://github.com/nojhan/liquidprompt/issues/315
cat <<EOF
Now drawing from 'AC Power'
EOF
;;
attached)
# https://github.com/nojhan/liquidprompt/issues/326#issuecomment-66120495
cat <<'EOF'
Now drawing from 'AC Power'
-InternalBattery-0 37%; AC attached; not charging
EOF
;;
charging)
# https://github.com/nojhan/liquidprompt/issues/326
cat <<'EOF'
Now drawing from 'AC Power'
-InternalBattery-0 8%; charging; 2:46 remaining
EOF
;;
discharging)
# https://github.com/nojhan/liquidprompt/issues/326
cat <<'EOF'
Now drawing from 'Battery Power'
-InternalBattery-0 9%; discharging; (no estimate)
EOF
;;
warning-Early)
# https://github.com/nojhan/liquidprompt/issues/326
cat <<'EOF'
Now drawing from 'Battery Power'
-InternalBattery-0 7%; discharging; 0:13 remaining
Battery Warning: Early
EOF
;;
*)
echo "unsupported '$pmset_sim' pmset simulation"
;;
esac
}

14
test.sh
View File

@ -1,6 +1,20 @@
#!/bin/sh
# Run the testsuite with both bash and zsh
if [ -z "$BASH_VERSION$ZSH_VERSION" ]; then
for sh in bash zsh
do
if [ -x /bin/$sh ]; then
/bin/$sh "$0"
elif [ -x /usr/bin/$sh ]; then
/usr/bin/$sh "$0"
fi
done
exit 0
fi
print_ok()
{
local OK="\\033[1;32m"