Release v1.9

This commit is contained in:
Olivier Mengué 2014-11-12 23:44:59 +01:00
commit 6c6e1f5e76
9 changed files with 1079 additions and 270 deletions

31
.mailmap Normal file
View File

@ -0,0 +1,31 @@
nojhan <nojhan@nojhan.net> <johann.dreo@thalesgroup.com>
nojhan <nojhan@nojhan.net> <nojhan@gmail.com>
Alexander Belaev (alexbel) <alexbel@lavabit.com>
Alex Prengere <alexprengere@gmail.com> <alex.prengere@amadeus.com>
Alex Prengere <alexprengere@gmail.com> Alex <alexprengere@gmail.com>
Aurélien Requiem <aurelien@requiem.fr> <aurelien.requiem@loadedtech.com.au>
Aurélien Requiem <aurelien@requiem.fr>
Clément Mathieu <clement@unportant.info>
François Schmidts (jaesivsm) <francois.schmidts@gmail.com>
François Schmidts (jaesivsm) <francois.schmidts@gmail.com> <fschmidts@olfeo.com>
François Schmidts (jaesivsm) <francois.schmidts@gmail.com> <jaesivsm>
Frédéric Lepied <flepied@gmail.com>
Étienne Deparis <etienne@depar.is>
Étienne Deparis <etienne@depar.is> <etienne.deparis@umaneti.net>
Felix Chern (dryman) <idryman@gmail.com>
Jean-Sébastien Leroy <jean.sebastien.leroy@gmail.com>
Joris Dedieu <joris@nfrance.com>
Joris Dedieu <joris@nfrance.com> <joris@pontiac3.nfrance.com>
Julien Pecqueur <jpec@julienpecqueur.net>
Julien Pecqueur <jpec@julienpecqueur.net> <jpec80@gmail.com>
Ludovic Rousseau <ludovic.rousseau@gmail.com> <lroussea@370bh2j.(none)>
Matthew Micene (nzwulfin) <nzwulfin@gmail.com>
Nicolas Lacourte <nicolas@dotinfra.fr>
Olivier Dupuis <oj.dupuis@gmail.com>
Poil <poil@quake.fr> M.Poil <?@?>
Poil <poil@quake.fr> Poil <?@?>
Thomas Debesse <thomas.debesse@gmail.com>
Rolf Morel (polyphemus) <rolfmorel@gmail.com>
Wilson Maravilha (algaerhythm) <algaerhythm@gmail.com>
Yannack <yannack@gmail.com>

81
CHANGES Normal file
View File

@ -0,0 +1,81 @@
1.9 2014-11-?? dolmen (Olivier Mengué)
Bug fixes:
- Battery indicator:
* 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)
- CPU load:
* Darwin/BSD: quoting fixes
- Hostname:
* Fix colorization for SSH
* Simplify chroot detection
- VCS:
- Git:
* Use --porcelain for "git status" (Github #270)
* Minir optimization (Github #266)
- Fossil:
* Cleanup and fixes (Github #274 and others)
- Subversion:
* Fix branch/tag name extraction (Github #117, #237, #293)
- Bazar:
* Fix branch name extraction
* zsh fixes (Github #303)
- Mercurial:
* General cleanup for speed and fixes
* 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)
- Analog clock:
* Fix hour for 12AM and 12PM (Github #273)
- Misc:
* bash: save and set 'promptvars'
* 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)
* Various quoting fixes
* Apply some shellcheck.com suggestions
* Many, many optimizations (Github #267)
New features:
- 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, Frençois Schmidts, Linus Wallgren, Alexander Belaev, Bartosz
Janda, Brett McBride, Chase Colman, Cosmin L. Neagu, Matthew Micene,
Vincent Lara, Wilson Maravilha and Yannack for their patches. Thanks
to all the other contributors who reported issues or proposed patches
that have not been applied.
1.8 2014-01-15 dolmen (Olivier Mengué)
1.7 2013-11-30 nojhan
1.6 2013-05-14 nojhan
1.5 2013-04-20 nojhan
1.4 2013-04-11 nojhan
1.3 2013-03-11 nojhan
1.2 2013-01-16 nojhan
1.1 2012-08-16 nojhan
1.0 2012-08-10 nojhan
0.0 2011-02-05 nojhan

661
LICENSE Normal file
View File

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

View File

@ -1,4 +1,4 @@
Liquid prompt -- A useful adaptive prompt for Bash & Zsh
Liquid prompt A useful adaptive prompt for Bash & Zsh
========================================================
Liquid prompt gives you a nicely displayed prompt with useful information
@ -24,7 +24,7 @@ A liquid prompt displaying everything (a rare event!) may look like this:
`code 🕤 ⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt][pyenv]↥ master(+10/-5,3)*+ 125 ± `
It (may) displays:
It (may) display:
* A tag associated to the current shell session (you can easily add any
prefix tag to your prompt, by invoking `prompt_tag MYTAG`).
@ -65,7 +65,7 @@ commits to push;
number of pending commits, if any;
* a yellow plus if there is stashed modifications;
* a red star if there is some untracked files in the repository;
* the runtime of the last command, if it has exceeded a certain threshold
* the runtime of the last command, if it has exceeded a certain threshold;
* 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 git-svn, ⌘ for fossil, $ or % for simple user, a red # for root;
@ -124,14 +124,14 @@ Apart from obvious ones, some features depend on specific commands. If you do
not install them, the corresponding feature will not be available, but you will
see no error.
* battery status needs `acpi`.
* temperature status needs `lm-sensors`.
* battery status needs `acpi` on GNU/Linux.
* temperature status needs `acpi` or `lm-sensors` on GNU/Linux.
* detached sessions is looking for `screen` and/or `tmux`.
* VCS support features needs… `git`, `hg`, `svn`, `bzr` or `fossil`, but you
knew it.
For other features, the script uses commands that should be available on a large
variety of unixes: `tput`, `grep`, `awk`, `sed`, `ps`, `who`.
variety of unixes: `tput`, `grep`, `awk`, `sed`, `ps`, `who`, `expr`.
## FEATURES CONFIGURATION
@ -324,7 +324,7 @@ Special characters:
* `LP_MARK_FOSSIL` (default: "⌘") prompt mark in fossil repositories
* `LP_MARK_BZR` (default: "⚯") prompt mark in bazaar repositories
* `LP_MARK_DISABLED` (default: "⌀") prompt mark in disabled repositories (see `LP_DISABLED_VCS_PATH`)
* `LP_MARK_UNTRACKED` (default: "*") if git has untracked files
* `LP_MARK_UNTRACKED` (default: "\*") if git has untracked files
* `LP_MARK_STASH` (default: "+") if git has stashed modifications
* `LP_MARK_BRACKET_OPEN` (default: "[") marks around the main part of the prompt
* `LP_MARK_BRACKET_CLOSE` (default: "]") marks around the main part of the prompt
@ -336,8 +336,8 @@ Special characters:
## KNOWN LIMITATIONS AND BUGS
Liquid prompt is distributed under the GNU Affero General Public License
version 3.
Liquid prompt is distributed under the [GNU Affero General Public License
version 3](LICENSE).
* Does not display the number of commits to be pushed in Mercurial repositories.
* Browsing into very large subversion repositories may dramatically slow down
@ -352,3 +352,11 @@ sufficiently complete font on your system.
The [Symbola](http://users.teilar.gr/~g1951d/) font, designed by Georges Douros,
is known to work well.
* Displaying the runtime currently only works with bash
## AUTHORS
Current Maintainer: [![endorse](https://api.coderwall.com/dolmen/endorsecount.png)](https://coderwall.com/dolmen)
Original author: [![endorse](https://api.coderwall.com/nojhan/endorsecount.png)](https://coderwall.com/nojhan)
And many contributors!

View File

@ -11,13 +11,18 @@
# LP_HOST hostname
# LP_PERM a colon ":"
# LP_PWD current working directory
# LP_VENV Python virtual environment
# LP_PROXY HTTP proxy
# LP_VCS the content of the current repository
# LP_ERR last error code
# LP_MARK prompt mark
# LP_TIME current time
# 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)
# LP_PS1_POSTFIX user-defined general-purpose postfix
# LP_BRACKET_OPEN open bracket
# LP_BRACKET_CLOSE close bracket
# Remember that most features come with their corresponding colors,
# see the README.
@ -25,29 +30,23 @@
# add time, jobs, load and battery
LP_PS1="${LP_PS1_PREFIX}${LP_TIME}${LP_BATT}${LP_LOAD}${LP_JOBS}"
# add user, host and permissions colon
LP_PS1="${LP_PS1}[${LP_USER}${LP_HOST}${LP_PERM}"
LP_PS1="${LP_PS1}${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_PERM}"
LP_PS1="${LP_PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}"
# Add VCS infos
# If root, the info has not been collected unless LP_ENABLE_VCS_ROOT
# is set.
LP_PS1="${LP_PS1}${LP_VCS}"
# if not root
if [[ "$EUID" -ne "0" ]]
then
# path in foreground color
LP_PS1="${LP_PS1}${LP_PWD}]${LP_VENV}${LP_PROXY}"
# add VCS infos
LP_PS1="${LP_PS1}${LP_VCS}"
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_VCS}"
fi
# add return code and prompt mark
LP_PS1="${LP_PS1}${LP_RUNTIME}${LP_ERR}${LP_MARK}"
LP_PS1="${LP_PS1}${LP_RUNTIME}${LP_ERR}${LP_MARK_PREFIX}${LP_MARK}${LP_PS1_POSTFIX}"
# "invisible" parts
# Get the current prompt on the fly and make it a title
LP_TITLE=$(_lp_title $PS1)
LP_TITLE="$(_lp_title "$LP_PS1")"
# Insert it in the prompt
PS1="${LP_TITLE}${PS1}"
LP_PS1="${LP_TITLE}${LP_PS1}"
# vim: set et sts=4 sw=4 tw=120 ft=sh:

View File

@ -8,20 +8,21 @@
# 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 [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]]; then
# If charset is UTF-8.
LP_MARK_BATTERY="⌁" # in front of the battery charge
LP_MARK_ADAPTER="⏚" # displayed when plugged
LP_MARK_LOAD="⌂" # in front of the load
LP_MARK_TEMP="θ" # in front of the temp
LP_MARK_PROXY="↥" # indicate a proxy in use
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_BATTERY="⌁" # in front of the battery charge
LP_MARK_ADAPTER="⏚" # displayed when plugged
LP_MARK_LOAD="⌂" # in front of the load
LP_MARK_TEMP="θ" # in front of the temp
LP_MARK_PROXY="↥" # indicate a proxy in use
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
LP_MARK_STASH="+" # if git has stashs
LP_MARK_SHORTEN_PATH="…" # prompt mark in shortened paths
LP_MARK_DISABLED="⌀" # prompt mark in directory with disabled VCS info
LP_MARK_UNTRACKED="*" # if git has untracked files
LP_MARK_STASH="+" # if git has stashs
LP_MARK_SHORTEN_PATH=" … " # prompt mark in shortened paths
else
# If charset is anything else, fallback to ASCII chars
LP_MARK_BATTERY="b"
@ -33,19 +34,25 @@ else
LP_MARK_SVN="="
LP_MARK_GIT="+"
LP_MARK_FOSSIL="f"
LP_MARK_DISABLED="!"
LP_MARK_UNTRACKED="*"
LP_MARK_STASH="+"
LP_MARK_SHORTEN_PATH="..."
LP_MARK_SHORTEN_PATH=" ... "
fi
# Do not prefix the prompt
LP_MARK_BRACKET_OPEN="[" # open bracket
LP_MARK_BRACKET_CLOSE="]" # close bracket
#LP_MARK_DEFAULT="" # default prompt mark
LP_MARK_PREFIX=" " # prompt mark prefix
LP_PS1_PREFIX=""
LP_PS1_POSTFIX=""
# 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,
# GREEN, BOLD_GREEN, YELLOW, BOLD_YELLOW, BLUE,
# BOLD_BLUE, PURPLE, PINK, CYAN, BOLD_CYAN
# Set to a null string "" if you do not want color.
# Current working directory
@ -73,13 +80,14 @@ 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="$BLUE" # connected via SSH
LP_COLOR_TELNET="$WARN_RED" # connected via telnet
LP_COLOR_X11_ON="$GREEN" # connected with X11 support
LP_COLOR_X11_OFF="$YELLOW" # connected without X11 support
LP_COLOR_HOST="" # local host
LP_COLOR_SSH="$BLUE" # connected via SSH
LP_COLOR_SU="$BOLD_YELLOW" # connected remotely but in new environment through su/sudo
LP_COLOR_TELNET="$WARN_RED" # connected via telnet
LP_COLOR_X11_ON="$GREEN" # connected with X11 support
LP_COLOR_X11_OFF="$YELLOW" # connected without X11 support
# Separation mark (aka permiison in the working dir)
# Separation mark (aka permission in the working dir)
LP_COLOR_WRITE="$GREEN" # have write permission
LP_COLOR_NOWRITE="$RED" # do not have write permission
@ -98,7 +106,10 @@ LP_COLOR_DISCHARGING_UNDER="$RED" # discharging and under threshold
# Time
LP_COLOR_TIME="$BLUE"
# Virtualenv
# Brackets inside screen/tmux
LP_COLOR_IN_MULTIPLEXER="$BOLD_BLUE"
# Virtual environment
LP_COLOR_VIRTUALENV="$CYAN"
# Runtime

View File

@ -50,7 +50,7 @@
# See the README.md file for a summary of features.
# Issue #161: do not load if not an interactive shell
test -z "$TERM" -o "x$TERM" = dumb && return
test -z "$TERM" -o "x$TERM" = xdumb && return
# Check for recent enough version of bash.
if test -n "$BASH_VERSION" -a -n "$PS1" ; then
@ -59,6 +59,7 @@ if test -n "$BASH_VERSION" -a -n "$PS1" ; then
unset bash bmajor bminor
return
fi
unset bash bmajor bminor
_LP_SHELL_bash=true
@ -71,6 +72,12 @@ if test -n "$BASH_VERSION" -a -n "$PS1" ; then
_LP_MARK_SYMBOL='\$'
_LP_FIRST_INDEX=0
_LP_PWD_SYMBOL="\\w"
_LP_PERCENT='%' # percent must be escaped on zsh
# Disable the DEBUG trap used by the RUNTIME feature
# (in case we are reloading LP in the same shell after disabling
# the feature in .liquidpromptrc)
# FIXME this doesn't seem to work :(
[[ -n "$LP_ENABLE_RUNTIME" ]] && trap - DEBUG
elif test -n "$ZSH_VERSION" ; then
_LP_SHELL_bash=false
_LP_SHELL_zsh=true
@ -81,12 +88,34 @@ elif test -n "$ZSH_VERSION" ; then
_LP_TIME_SYMBOL="%*"
_LP_MARK_SYMBOL='%(!.#.%%)'
_LP_FIRST_INDEX=1
_LP_PERCENT='%%'
_LP_PWD_SYMBOL="%~"
else
echo "liquidprompt: shell not supported" >&2
return
fi
# Store $2 (or $?) as a true/false value in variable named $1
# $? is propagated
# _lp_bool foo 5
# => foo=false
# _lp_bool foo 0
# => foo=true
_lp_bool()
{
local res=${2:-$?}
if [[ $res = 0 ]]; then
eval $1=true
else
eval $1=false
fi
return $res
}
# Save $IFS as we want to restore the default value at the beginning of the
# prompt function
_LP_IFS="$IFS"
###############
# OS specific #
@ -130,7 +159,7 @@ case "$LP_OS" in
# If you have problems with syntax coloring due to the following
# line, do this: ln -s liquidprompt liquidprompt.bash
# and edit liquidprompt.bash
read bol load eol <<<$( LANG=C sysctl -n vm.loadavg )
read bol load eol <<<"$( LANG=C sysctl -n vm.loadavg )"
echo "$load"
}
;;
@ -163,18 +192,31 @@ _lp_source_config()
local ti_sgr0="$( { tput sgr0 || tput me ; } 2>/dev/null )"
local ti_bold="$( { tput bold || tput md ; } 2>/dev/null )"
local ti_setaf
if tput setaf >/dev/null 2>&1 ; then
ti_setaf () { tput setaf "$1" ; }
elif tput AF >/dev/null 2>&1 ; then
# *BSD
ti_setaf () { tput AF "$1" ; }
elif tput AF 1 >/dev/null 2>&1 ; then
local ti_setab
if tput setaf 0 >/dev/null 2>&1; then
ti_setaf() { tput setaf "$1" ; }
elif tput AF 0 >/dev/null 2>&1; then
# FreeBSD
ti_setaf() { tput AF "$1" ; }
elif tput AF 0 0 0 >/dev/null 2>&1; then
# OpenBSD
ti_setaf () { tput AF "$1" ; }
ti_setaf() { tput AF "$1" 0 0 ; }
else
echo "liquidprompt: terminal $TERM not supported" >&2
ti_setaf () { : ; }
fi
if tput setab 0 >/dev/null 2>&1; then
ti_setab() { tput setab "$1" ; }
elif tput AB 0 >/dev/null 2>&1; then
# FreeBSD
ti_setab() { tput AB "$1" ; }
elif tput AB 0 0 0 >/dev/null 2>&1; then
# OpenBSD
ti_setab() { tput AB "$1" 0 0 ; }
else
echo "liquidprompt: terminal $TERM not supported" >&2
ti_setab() { : ; }
fi
# Colors: variables are local so they will have a value only
# during config loading and will not conflict with other values
@ -188,9 +230,9 @@ _lp_source_config()
local RED="${_LP_OPEN_ESC}$(ti_setaf 1)${_LP_CLOSE_ESC}"
local BOLD_RED="${_LP_OPEN_ESC}${ti_bold}$(ti_setaf 1)${_LP_CLOSE_ESC}"
local WARN_RED="${_LP_OPEN_ESC}$(ti_setaf 0 ; tput setab 1)${_LP_CLOSE_ESC}"
local CRIT_RED="${_LP_OPEN_ESC}${ti_bold}$(ti_setaf 7 ; tput setab 1)${_LP_CLOSE_ESC}"
local DANGER_RED="${_LP_OPEN_ESC}${ti_bold}$(ti_setaf 3 ; tput setab 1)${_LP_CLOSE_ESC}"
local WARN_RED="${_LP_OPEN_ESC}$(ti_setaf 0 ; ti_setab 1)${_LP_CLOSE_ESC}"
local CRIT_RED="${_LP_OPEN_ESC}${ti_bold}$(ti_setaf 7 ; ti_setab 1)${_LP_CLOSE_ESC}"
local DANGER_RED="${_LP_OPEN_ESC}${ti_bold}$(ti_setaf 3 ; ti_setab 1)${_LP_CLOSE_ESC}"
local GREEN="${_LP_OPEN_ESC}$(ti_setaf 2)${_LP_CLOSE_ESC}"
local BOLD_GREEN="${_LP_OPEN_ESC}${ti_bold}$(ti_setaf 2)${_LP_CLOSE_ESC}"
@ -210,7 +252,13 @@ _lp_source_config()
# NO_COL is special: it will be used at runtime, not just during config loading
NO_COL="${_LP_OPEN_ESC}${ti_sgr0}${_LP_CLOSE_ESC}"
unset ti_sgr0 ti_bold ti_setaf
# compute the hash of the hostname
# and get the corresponding number in [1-6] (red,green,yellow,blue,purple or cyan)
# FIXME check portability of cksum and add more formats (bold? 256 colors?)
local hash=$(( 1 + $(hostname | cksum | cut -d " " -f 1) % 6 ))
LP_COLOR_HOST_HASH="${_LP_OPEN_ESC}$(ti_setaf $hash)${_LP_CLOSE_ESC}"
unset ti_sgr0 ti_bold ti_setaf ti_setab
# Default values (globals)
@ -241,6 +289,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_VCSH=${LP_ENABLE_VCSH:-1}
LP_ENABLE_FOSSIL=${LP_ENABLE_FOSSIL:-1}
LP_ENABLE_HG=${LP_ENABLE_HG:-1}
LP_ENABLE_BZR=${LP_ENABLE_BZR:-1}
@ -251,13 +300,14 @@ _lp_source_config()
LP_ENABLE_RUNTIME=${LP_ENABLE_RUNTIME:-0}
fi
LP_ENABLE_VIRTUALENV=${LP_ENABLE_VIRTUALENV:-1}
LP_ENABLE_SCLS=${LP_ENABLE_SCLS:-1}
LP_ENABLE_VCS_ROOT=${LP_ENABLE_VCS_ROOT:-0}
LP_ENABLE_TITLE=${LP_ENABLE_TITLE:-0}
LP_ENABLE_SCREEN_TITLE=${LP_ENABLE_SCREEN_TITLE:-0}
LP_ENABLE_SSH_COLORS=${LP_ENABLE_SSH_COLORS:-0}
# LP_DISABLED_VCS_PATH="${LP_DISABLED_VCS_PATH}"
# LP_MARK_DEFAULT="$LP_MARK_DEFAULT"
LP_MARK_DEFAULT="${LP_MARK_DEFAULT:-$_LP_MARK_SYMBOL}"
LP_MARK_BATTERY="${LP_MARK_BATTERY:-"⌁"}"
LP_MARK_ADAPTER="${LP_MARK_ADAPTER:-"⏚"}"
LP_MARK_LOAD="${LP_MARK_LOAD:-"⌂"}"
@ -266,6 +316,7 @@ _lp_source_config()
LP_MARK_HG="${LP_MARK_HG:-"☿"}"
LP_MARK_SVN="${LP_MARK_SVN:-"‡"}"
LP_MARK_GIT="${LP_MARK_GIT:-"±"}"
LP_MARK_VCSH="${LP_MARK_VCSH:-"|"}"
LP_MARK_FOSSIL="${LP_MARK_FOSSIL:-"⌘"}"
LP_MARK_BZR="${LP_MARK_BZR:-"⚯"}"
LP_MARK_DISABLED="${LP_MARK_DISABLED:-"⌀"}"
@ -274,7 +325,7 @@ _lp_source_config()
LP_MARK_BRACKET_OPEN="${LP_MARK_BRACKET_OPEN:-"["}"
LP_MARK_BRACKET_CLOSE="${LP_MARK_BRACKET_CLOSE:-"]"}"
LP_MARK_SHORTEN_PATH="${LP_MARK_SHORTEN_PATH:-" … "}"
# LP_MARK_PREFIX="$LP_MARK_PREFIX"
LP_MARK_PREFIX="${LP_MARK_PREFIX:-" "}"
LP_COLOR_PATH=${LP_COLOR_PATH:-$BOLD}
LP_COLOR_PATH_ROOT=${LP_COLOR_PATH_ROOT:-$BOLD_YELLOW}
@ -307,6 +358,7 @@ _lp_source_config()
LP_COLOR_TIME=${LP_COLOR_TIME:-$BLUE}
LP_COLOR_IN_MULTIPLEXER=${LP_COLOR_IN_MULTIPLEXER:-$BOLD_BLUE}
LP_COLOR_RUNTIME=${LP_COLOR_RUNTIME:-$YELLOW}
LP_COLOR_VIRTUALENV=${LP_COLOR_VIRTUALENV:-$CYAN}
LP_COLORMAP_0=${LP_COLORMAP_0:-""}
LP_COLORMAP_1=${LP_COLORMAP_1:-$GREEN}
@ -358,6 +410,9 @@ case "$LP_OS" in
Darwin) [[ "$LP_ENABLE_BATT" = 1 ]] && { command -v pmset >/dev/null || LP_ENABLE_BATT=0 ; };;
*) [[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; };;
esac
command -v screen >/dev/null ; _lp_bool _LP_ENABLE_SCREEN $?
command -v tmux >/dev/null ; _lp_bool _LP_ENABLE_TMUX $?
$_LP_ENABLE_SCREEN || $_LP_ENABLE_TMUX ; _lp_bool _LP_ENABLE_DETACHED_SESSIONS $?
if [[ "$LP_ENABLE_RUNTIME" == 1 ]] && ! $_LP_SHELL_bash; then
echo Unfortunately, runtime printing for zsh is not yet supported. Turn LP_ENABLE_RUNTIME off in your config to hide this message.
@ -411,7 +466,7 @@ _lp_escape()
# Yellow for root, bold if the user is not the login one, else no color.
if [[ "$EUID" -ne "0" ]] ; then # if user is not root
# if user is not login user
if [[ ${USER} != "$(logname 2>/dev/null || echo $LOGNAME)" ]]; then
if [[ ${USER} != "$(logname 2>/dev/null || echo "$LOGNAME")" ]]; then
LP_USER="${LP_COLOR_USER_ALT}${_LP_USER_SYMBOL}${NO_COL}"
else
if [[ "${LP_USER_ALWAYS}" -ne "0" ]] ; then
@ -456,23 +511,14 @@ _lp_connection()
# Put the hostname if not locally connected
# color it in cyan within SSH, and a warning red if within telnet
# else diplay the host without color
# else display the host without color
# The connection is not expected to change from inside the shell, so we
# build this just once
LP_HOST=""
_chroot()
{
if [[ -r /etc/debian_chroot ]] ; then
local debchroot
debchroot="$(< /etc/debian_chroot)"
echo "(${debchroot})"
fi
}
LP_HOST="$(_chroot)"
unset _chroot
[[ -r /etc/debian_chroot ]] && LP_HOST="($(< /etc/debian_chroot))"
# If we are connected with a X11 support
if [[ -n "$DISPLAY" ]] ; then
if [[ -n "$DISPLAY" ]]; then
LP_HOST="${LP_COLOR_X11_ON}${LP_HOST}@${NO_COL}"
else
LP_HOST="${LP_COLOR_X11_OFF}${LP_HOST}@${NO_COL}"
@ -489,19 +535,8 @@ lcl)
;;
ssh)
# If we want a different color for each host
if [[ "$LP_ENABLE_SSH_COLORS" -eq "1" ]]; then
# compute the hash of the hostname
# and get the corresponding number in [1-6] (red,green,yellow,blue,purple or cyan)
# FIXME check portability of cksum and add more formats (bold? 256 colors?)
hash=$(( 1 + $(hostname | cksum | cut -d " " -f 1) % 6 ))
color=${_LP_OPEN_ESC}$(ti_setaf $hash)${_LP_CLOSE_ESC}
LP_HOST="${LP_HOST}${color}${_LP_HOST_SYMBOL}${NO_COL}"
unset hash
unset color
else
# the same color for all hosts
LP_HOST="${LP_HOST}${LP_COLOR_SSH}${_LP_HOST_SYMBOL}${NO_COL}"
fi
[[ "$LP_ENABLE_SSH_COLORS" -eq 1 ]] && LP_COLOR_SSH="$LP_COLOR_HOST_HASH"
LP_HOST="${LP_HOST}${LP_COLOR_SSH}${_LP_HOST_SYMBOL}${NO_COL}"
;;
su)
LP_HOST="${LP_HOST}${LP_COLOR_SU}${_LP_HOST_SYMBOL}${NO_COL}"
@ -518,6 +553,12 @@ esac
unset _lp_connection
_lp_get_home_tilde_collapsed()
{
local tilde="~"
echo "${PWD/#$HOME/$tilde}"
}
# Shorten the path of the current working directory
# * Show only the current directory
# * Show as much of the cwd path as possible, if shortened display a
@ -536,15 +577,15 @@ _lp_shorten_path()
local ret=""
local p="${PWD/#$HOME/~}"
local p="$(_lp_get_home_tilde_collapsed)"
local mask="${LP_MARK_SHORTEN_PATH}"
local -i max_len=$(( ${COLUMNS:-80} * $LP_PATH_LENGTH / 100 ))
local -i max_len=$(( ${COLUMNS:-80} * LP_PATH_LENGTH / 100 ))
if [[ ${LP_PATH_KEEP} == -1 ]]; then
# only show the current directory, excluding any parent dirs
ret="${p##*/}" # discard everything upto and including the last slash
ret="${p##*/}" # discard everything up to and including the last slash
[[ "${ret}" == "" ]] && ret="/" # if in root directory
elif (( ${#p} <= ${max_len} )); then
elif (( ${#p} <= max_len )); then
ret="${p}"
elif [[ ${LP_PATH_KEEP} == 0 ]]; then
# len is over max len, show as much of the tail as is allowed
@ -557,8 +598,8 @@ _lp_shorten_path()
local tmp=${p//\//}
local -i delims=$(( ${#p} - ${#tmp} ))
for (( dir=0; dir < ${LP_PATH_KEEP}; dir++ )); do
(( ${dir} == ${delims} )) && break
for (( dir=0; dir < LP_PATH_KEEP; dir++ )); do
(( dir == delims )) && break
local left="${p#*/}"
local name="${p:0:${#p} - ${#left}}"
@ -566,7 +607,7 @@ _lp_shorten_path()
ret="${ret}${name%/}/"
done
if (( ${delims} <= ${LP_PATH_KEEP} )); then
if (( delims <= LP_PATH_KEEP )); then
# no dirs between LP_PATH_KEEP leading dirs and current dir
ret="${ret}${p##*/}"
else
@ -576,7 +617,7 @@ _lp_shorten_path()
[[ ${ret} != "/" ]] && ret="${ret%/}" # strip trailing slash
local -i len_left=$(( ${max_len} - ${#ret} - ${#base} - ${#mask} ))
local -i len_left=$(( max_len - ${#ret} - ${#base} - ${#mask} ))
ret="${ret}${mask}${p:${#p} - ${len_left}}${base}"
fi
@ -594,8 +635,8 @@ _lp_shorten_path()
# liquidprompt can calculate this number under two condition, path shortening
# must be disabled and PROMPT_DIRTRIM must be already set.
_lp_set_dirtrim() {
local p="${PWD/$HOME/~}"
local -i max_len=${COLUMNS:-80}*$LP_PATH_LENGTH/100
local p="$(_lp_get_home_tilde_collapsed)"
local -i max_len="${COLUMNS:-80}*$LP_PATH_LENGTH/100"
local -i dt=0
if (( ${#p} > max_len )); then
@ -629,31 +670,30 @@ _lp_jobcount_color()
{
[[ "$LP_ENABLE_JOBS" != 1 ]] && return
local running=$(( $(jobs -r | wc -l) ))
local stopped=$(( $(jobs -s | wc -l) ))
local n_screen=$(screen -ls 2> /dev/null | grep -c '[Dd]etach[^)]*)$')
local n_tmux=$(tmux list-sessions 2> /dev/null | grep -cv attached)
local detached=$(( $n_screen + $n_tmux ))
local m_detached="d"
local m_stop="z"
local m_run="&"
local ret=""
local ret
if [[ $detached != "0" ]] ; then
ret="${ret}${LP_COLOR_JOB_D}${detached}${m_detached}${NO_COL}"
if $_LP_ENABLE_DETACHED_SESSIONS; then
local -i detached=0
$_LP_ENABLE_SCREEN && let detached=$(screen -ls 2> /dev/null | grep -c '[Dd]etach[^)]*)$')
$_LP_ENABLE_TMUX && let detached+=$(tmux list-sessions 2> /dev/null | grep -cv 'attached')
(( detached > 0 )) && ret="${ret}${LP_COLOR_JOB_D}${detached}d${NO_COL}"
fi
if [[ $running != "0" ]] ; then
if [[ $ret != "" ]] ; then ret="${ret}/"; fi
local running=$(( $(jobs -r | wc -l) ))
if [[ $running != 0 ]] ; then
[[ -n "$ret" ]] && ret="${ret}/"
ret="${ret}${LP_COLOR_JOB_R}${running}${m_run}${NO_COL}"
fi
if [[ $stopped != "0" ]] ; then
if [[ $ret != "" ]] ; then ret="${ret}/"; fi
local stopped=$(( $(jobs -s | wc -l) ))
if [[ $stopped != 0 ]] ; then
[[ -n "$ret" ]] && ret="${ret}/"
ret="${ret}${LP_COLOR_JOB_Z}${stopped}${m_stop}${NO_COL}"
fi
echo -ne "$ret"
echo -n "$ret"
}
@ -679,9 +719,9 @@ _lp_are_vcs_enabled()
_lp_git_branch()
{
[[ "$LP_ENABLE_GIT" != 1 ]] && return
local gitdir
gitdir="$([ $(\git ls-files . 2>/dev/null | wc -l) -gt 0 ] && \git rev-parse --git-dir 2>/dev/null)"
[[ $? -ne 0 || ! $gitdir =~ (.*\/)?\.git.* ]] && return
\git rev-parse --inside-work-tree >/dev/null 2>&1 || return
local branch
# Recent versions of Git support the --short option for symbolic-ref, but
# not 1.7.9 (Ubuntu 12.04)
@ -710,27 +750,25 @@ _lp_git_branch_color()
local end
end="$NO_COL"
if LC_ALL=C \git status 2>/dev/null | grep -q '\(# Untracked\)'; then
if LC_ALL=C \git status --porcelain 2>/dev/null | grep -Eq '^\?\?'; then
end="$LP_COLOR_CHANGES$LP_MARK_UNTRACKED$end"
fi
if [[ -n "$(\git stash list 2>/dev/null)" ]]; then
if [[ -n "$(\git stash list -n 1 2>/dev/null)" ]]; then
end="$LP_COLOR_COMMITS$LP_MARK_STASH$end"
fi
local remote
remote="$(\git config --get branch.${branch}.remote 2>/dev/null)"
local has_commit
local -i has_commit
has_commit=0
if [[ -n "$remote" ]] ; then
if [[ -n "$remote" ]]; then
local remote_branch
remote_branch="$(\git config --get branch.${branch}.merge)"
if [[ -n "$remote_branch" ]] ; then
has_commit="$(\git rev-list --no-merges --count ${remote_branch/refs\/heads/refs\/remotes\/$remote}..HEAD 2>/dev/null)"
if [[ -z "$has_commit" ]] ; then
has_commit=0
fi
if [[ -n "$remote_branch" ]]; then
has_commit="$(\git rev-list --count ${remote_branch/refs\/heads/refs\/remotes\/$remote}..HEAD 2>/dev/null)"
[[ -z "$has_commit" ]] && has_commit=0
fi
fi
@ -827,32 +865,35 @@ _lp_hg_branch_color()
if [[ -n "$branch" ]] ; then
local has_untracked
has_untracked=$(hg status 2>/dev/null | grep -c '\(^\?\)')
if [[ -z "$has_untracked" ]] ; then
has_untracked=""
else
has_untracked=
if hg status -u 2>/dev/null | grep -q '^\?' >/dev/null ; then
has_untracked="$LP_COLOR_CHANGES$LP_MARK_UNTRACKED"
fi
local has_commit
has_commit=$(hg outgoing --no-merges ${branch} 2>/dev/null | grep -c '\(^changeset\:\)')
if [[ -z "$has_commit" ]] ; then
has_commit=0
fi
# Count local commits waiting for a push
#
# Unfortunately this requires contacting the remote, so this is always slow
# => disabled https://github.com/nojhan/liquidprompt/issues/217
local -i commits
#commits=$(hg outgoing --no-merges ${branch} 2>/dev/null | grep -c '\(^changeset\:\)')
commits=0
if [[ $(( $(hg status --quiet -n | wc -l) )) = 0 ]] ; then
if [[ "$has_commit" -gt "0" ]] ; then
# Check if there is some uncommitted stuff
if [[ -z "$(hg status --quiet -n)" ]] ; then
if (( commits > 0 )) ; then
# some commit(s) to push
ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})${has_untracked}${NO_COL}"
ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$commits${NO_COL})${has_untracked}${NO_COL}"
else
ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}" # nothing to commit or push
# nothing to commit or push
ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}"
fi
else
local has_lines
has_lines=$(hg diff --stat 2>/dev/null | tail -n 1 | awk 'FS=" " {printf("+%s/-%s\n", $4, $6)}')
if [[ "$has_commit" -gt "0" ]] ; then
# Parse the last line of the diffstat-style output
has_lines="$(hg diff --stat 2>/dev/null | sed -n '$ s!^.*, \([0-9]*\) .*, \([0-9]*\).*$!+\1/-\2!p')"
if (( commits > 0 )) ; then
# Changes to commit and commits to push
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})${has_untracked}${NO_COL}"
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$commits${NO_COL})${has_untracked}${NO_COL}"
else
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})${has_untracked}${NO_COL}" # changes to commit
fi
@ -870,15 +911,21 @@ _lp_svn_branch()
[[ "$LP_ENABLE_SVN" != 1 ]] && return
local root
local url
eval $(LANG=C LC_ALL=C svn info 2>/dev/null | sed -n 's/^URL: \(.*\)/url="\1"/p;s/^Repository Root: \(.*\)/root="\1"/p' )
eval "$(LANG=C LC_ALL=C svn info 2>/dev/null | sed -n 's/^URL: \(.*\)/url="\1"/p;s/^Repository Root: \(.*\)/root="\1"/p' )"
[[ -z "$root" ]] && return
# Make url relative to root
url="${url:${#root}}"
if [[ "$url" == */trunk* ]] ; then
echo -n trunk
elif [[ "$url" == */branches/?* ]] ; then
url="${url##*/branches/}"
_lp_escape "${url%/*}"
elif [[ "$url" == */tags/?* ]] ; then
url="${url##*/tags/}"
_lp_escape "${url%/*}"
else
_lp_escape "$(expr "$url" : '.*/branches/\([^/]*\)' || expr "$url" : '/\([^/]*\)' || basename "$root")"
_lp_escape "${root##*/}"
fi
}
@ -896,7 +943,7 @@ _lp_svn_branch_color()
local branch
branch="$(_lp_svn_branch)"
if [[ -n "$branch" ]] ; then
local commits
local changes
changes=$(( $(svn status $LP_SVN_STATUS_OPTIONS | grep -c -v "?") ))
if [[ $changes -eq 0 ]] ; then
echo "${LP_COLOR_UP}${branch}${NO_COL}"
@ -914,9 +961,9 @@ _lp_fossil_branch()
{
[[ "$LP_ENABLE_FOSSIL" != 1 ]] && return
local branch
branch="$(fossil status 2>/dev/null | grep tags: | cut -c17-)"
if [[ -n "$branch" ]] ; then
_lp_escape "$branch"
branch=$(fossil status 2>/dev/null | sed -n "s/tags:[ ]*\(\w*\)$/\1/Ip")
if [ -n "$branch" ]; then
echo "$branch"
else
if fossil info &>/dev/null ; then
echo "no-tag"
@ -939,76 +986,30 @@ _lp_fossil_branch_color()
local branch
branch="$(_lp_fossil_branch)"
if [[ -n "$branch" ]] ; then
local C2E # Modified files (added or edited)
local C2D # Deleted files
if [ -n "$branch" ]; then
local -i C2E # Modified files (added or edited)
local C2A # Extras files
local C2AA # Added files
local PLUSLINE # Added lines
local MINUSLINE # Deleted lines
local ret
C2E=$(fossil changes | wc -l)
C2A=$(fossil extras | wc -l)
PLUSLINE=$(fossil diff | egrep -c '^\+[^+].+$')
MINUSLINE=$(fossil diff | egrep -c '^-[^-].+$')
ret=""
ret=$(fossil diff -i -v | awk "/^(+[^+])|(+$)/ { plus+=1; } /^(-[^-])|(-$)/ { minus+=1; } END { total=\"\"; if(plus>0){ total=\"+\"plus; if(minus>0) total=total\"/\"; } if(minus>0) total=total\"-\"minus; print total;}")
C2AA=$(fossil changes | grep -c "ADDED")
if [[ $C2AA -gt 0 ]] ; then
# We count the line "à la" git
local ADDFILE
local FILE
ADDFILE=$(fossil changes | grep ADDED | sed -e 's/\s\{2,\}/ /g' | cut -d" " -f2)
for FILE in $ADDFILE ; do
PLULI=$(wc -l < $FILE)
let PLUSLINE=$PLUSLINE+$PLULI
done
if (( C2E > 0 )); then
[[ -n "$ret" ]] && ret+=" in "
ret="(${LP_COLOR_DIFF}${ret}${C2E}${NO_COL})"
fi
if [[ $PLUSLINE -gt 0 ]] ; then
ret+="+$PLUSLINE"
fi
C2D=$(fossil changes | grep -c "DELETED")
if [[ $C2D -gt 0 ]] ; then
# We count the line "à la" git
local DELFILE
local FILE
DELFILE=$(fossil changes | grep DELETED | sed -e 's/\s\{2,\}/ /g' | cut -d" " -f2)
for FILE in $DELFILE ; do
MINLI=$(wc -l < $FILE)
let MINUSLINE=$MINUSLINE+$MINLI
done
fi
if [[ $MINUSLINE -gt 0 ]] ; then
if [[ "$ret" = "" ]] ; then
ret+="-$MINUSLINE"
else
ret+="/-$MINUSLINE"
fi
fi
if [[ "$C2E" -gt 0 ]] ; then
ret+=" in $C2E"
fi
if [[ "$C2A" -gt 0 ]] ; then
C2A="$LP_MARK_UNTRACKED"
if (( C2A > 0 )); then
C2A="$LP_COLOR_CHANGES$LP_MARK_UNTRACKED"
else
C2A=""
fi
if [[ "$ret" != "" ]] ; then
ret="(${LP_COLOR_DIFF}$ret${NO_COL})"
fi
if [[ "$branch" = "no-tag" ]] ; then
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
if (( C2E == 0 )); then
# All is up-to-date
branch="${LP_COLOR_UP}$branch$C2A${NO_COL}"
else
@ -1016,7 +1017,7 @@ _lp_fossil_branch_color()
branch="${LP_COLOR_CHANGES}$branch${NO_COL}$ret${LP_COLOR_CHANGES}$C2A${NO_COL}"
fi
fi
_lp_escape "$branch"
echo "$branch"
fi
}
@ -1063,7 +1064,10 @@ _lp_bzr_branch_color()
local output
output="$(bzr version-info --check-clean --custom --template='{branch_nick} {revno} {clean}' 2> /dev/null)"
[[ $? -ne 0 ]] && return
local tuple=($output)
$_LP_SHELL_zsh && setopt local_options && setopt sh_word_split
local tuple
tuple=($output)
$_LP_SHELL_zsh && unsetopt sh_word_split
local branch=${tuple[_LP_FIRST_INDEX+0]}
local revno=${tuple[_LP_FIRST_INDEX+1]}
local clean=${tuple[_LP_FIRST_INDEX+2]}
@ -1103,7 +1107,7 @@ case "$LP_OS" in
Linux)
_lp_battery()
{
[[ "$LP_ENABLE_BATT" != 1 ]] && return
[[ "$LP_ENABLE_BATT" != 1 ]] && return 4
local acpi
acpi="$(acpi --battery 2>/dev/null)"
# Extract the battery load value in percent
@ -1144,12 +1148,12 @@ case "$LP_OS" in
Darwin)
_lp_battery()
{
[[ "$LP_ENABLE_BATT" != 1 ]] && return
local pmset="$(pmset -g batt | tail -n1)"
[[ "$LP_ENABLE_BATT" != 1 ]] && return 4
local pmset="$(pmset -g batt | sed -n -e '/InternalBattery/p')"
local bat="$(cut -f2 <<<"$pmset")"
bat="${bat%%%*}"
case "$pmset" in
*charged*)
*charged* | "")
return 4
;;
*discharging*)
@ -1220,34 +1224,31 @@ _lp_battery_color()
ret="${LP_COLOR_DISCHARGING_UNDER}${mark}${NO_COL}"
if [[ "$LP_PERCENTS_ALWAYS" -eq "1" ]]; then
if [[ ${bat} -le 100 ]] && [[ ${bat} -gt 80 ]] ; then # -20
ret="${ret}${LP_COLORMAP_1}"
elif [[ ${bat} -le 80 ]] && [[ ${bat} -gt 65 ]] ; then # -15
ret="${ret}${LP_COLORMAP_2}"
elif [[ ${bat} -le 65 ]] && [[ ${bat} -gt 50 ]] ; then # -15
ret="${ret}${LP_COLORMAP_3}"
elif [[ ${bat} -le 50 ]] && [[ ${bat} -gt 40 ]] ; then # -10
ret="${ret}${LP_COLORMAP_4}"
elif [[ ${bat} -le 40 ]] && [[ ${bat} -gt 30 ]] ; then # …
ret="${ret}${LP_COLORMAP_5}"
elif [[ ${bat} -le 30 ]] && [[ ${bat} -gt 20 ]] ; then
ret="${ret}${LP_COLORMAP_6}"
elif [[ ${bat} -le 20 ]] && [[ ${bat} -gt 10 ]] ; then
ret="${ret}${LP_COLORMAP_7}"
elif [[ ${bat} -le 10 ]] && [[ ${bat} -gt 5 ]] ; then
ret="${ret}${LP_COLORMAP_8}"
elif [[ ${bat} -le 5 ]] && [[ ${bat} -gt 0 ]] ; then
if (( bat <= 0 )); then
ret="${ret}${LP_COLORMAP_0}"
elif (( bat <= 5 )); then # 5
ret="${ret}${LP_COLORMAP_9}"
else
# for debugging purpose
elif (( bat <= 10 )); then # 5
ret="${ret}${LP_COLORMAP_8}"
elif (( bat <= 20 )); then # 10
ret="${ret}${LP_COLORMAP_7}"
elif (( bat <= 30 )); then # 10
ret="${ret}${LP_COLORMAP_6}"
elif (( bat <= 40 )); then # 10
ret="${ret}${LP_COLORMAP_5}"
elif (( bat <= 50 )); then # 10
ret="${ret}${LP_COLORMAP_4}"
elif (( bat <= 65 )); then # 15
ret="${ret}${LP_COLORMAP_3}"
elif (( bat <= 80 )); then # 15
ret="${ret}${LP_COLORMAP_2}"
elif (( bat < 100 )); then # 20
ret="${ret}${LP_COLORMAP_1}"
else # >= 100
ret="${ret}${LP_COLORMAP_0}"
fi
if $_LP_SHELL_bash; then
ret="${ret}${bat}%"
else # zsh
ret="${ret}${bat}%%"
fi
ret="${ret}${bat}$_LP_PERCENT"
fi # LP_PERCENTS_ALWAYS
echo -ne "${ret}${NO_COL}"
fi # ret
@ -1320,8 +1321,8 @@ _lp_reset_runtime()
[ "$_LP_RUNTIME_COMMAND_EXECUTED" != 1 ] && _LP_RUNTIME_LAST_SECONDS=$SECONDS && _LP_RUNTIME_SECONDS=0
# A proper command has been executed if the last command was not related to liquidprompt
[ "$BASH_COMMAND" = _lp_set_prompt ] && _LP_RUNTIME_COMMAND_EXECUTED=0 && return
_LP_RUNTIME_COMMAND_EXECUTED=1
[ "$BASH_COMMAND" = _lp_set_prompt ]
_LP_RUNTIME_COMMAND_EXECUTED=$?
}
if [ "$LP_ENABLE_RUNTIME" = 1 ]
@ -1352,15 +1353,11 @@ _lp_load_color()
tmp=${tmp#0} # Remove leading '0', again (ex: 0.09)
local -i load=${tmp:-0}/$_lp_CPUNUM
if (( load > $LP_LOAD_THRESHOLD )); then
if (( load > LP_LOAD_THRESHOLD )); then
local ret="$(_lp_color_map $load 200)${LP_MARK_LOAD}"
if [[ "$LP_PERCENTS_ALWAYS" == 1 ]]; then
if $_LP_SHELL_bash; then
ret="${ret}$load%"
else # zsh
ret="${ret}$load%%"
fi
ret="${ret}${load}${_LP_PERCENT}"
fi
echo -nE "${ret}${NO_COL}"
fi
@ -1383,7 +1380,7 @@ _lp_temp_sensors()
_lp_temp_acpi()
{
local i
for i in $(acpi -t | sed 's/.* \([0-9]*\)\.[0-9]* degrees C$/\1/p'); do
for i in $(LANG=C acpi -t | sed 's/.* \(-\?[0-9]*\)\.[0-9]* degrees C$/\1/p'); do
[[ $i -gt $temperature ]] && temperature=$i
done
}
@ -1447,18 +1444,13 @@ _lp_smart_mark()
case "$LP_VCS_TYPE" in
git) mark="$LP_MARK_GIT" ;;
git-svn) mark="$LP_MARK_GIT$LP_MARK_SVN" ;;
git-vcsh) mark="$LP_MARK_VCSH$LP_MARK_GIT$LP_MARK_VCSH";;
hg) mark="$LP_MARK_HG" ;;
svn) mark="$LP_MARK_SVN" ;;
fossil) mark="$LP_MARK_FOSSIL" ;;
bzr) mark="$LP_MARK_BZR" ;;
disabled) mark="$LP_MARK_DISABLED" ;;
*)
if [[ -n "$LP_MARK_DEFAULT" ]]; then
mark=$LP_MARK_DEFAULT
else
mark="$_LP_MARK_SYMBOL"
fi
;;
*) mark="$LP_MARK_DEFAULT" ;;
esac
echo -ne "${LP_COLOR_MARK}${mark}${NO_COL}"
}
@ -1505,8 +1497,8 @@ _lp_time_analog()
local -a half
half=(🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧 )
# array index starts at 0
local -i hi=hour-1
# "date %I" returns a number between 1 and 12 and we want 12 to be 0.
local -i hi=$(( hour % 12))
# add a space for correct alignment
if (( min < 15 )) ; then
@ -1543,16 +1535,19 @@ _lp_set_prompt()
if (( err != 0 )); then
LP_ERR=" $LP_COLOR_ERR$err$NO_COL"
else
LP_ERR= # Hidden
LP_ERR='' # Hidden
fi
# Reset IFS to its default value to avoid strange behaviors
# (in case the user is playing with the value at the prompt)
local IFS="$(echo -e ' \t')
" # space, tab, LF
local IFS="$_LP_IFS"
# execute the old prompt
eval "$LP_OLD_PROMPT_COMMAND"
if $_LP_SHELL_bash; then
eval "$LP_OLD_PROMPT_COMMAND"
else # zsh
eval "${${LP_OLD_PROMPT_COMMAND#*$'\n'}%$'\n'*}"
fi
# left of main prompt: space at right
LP_JOBS="$(_lp_sr "$(_lp_jobcount_color)")"
@ -1568,13 +1563,20 @@ _lp_set_prompt()
LP_PROXY=
fi
# Display the current Python virtual environnement, if available
# Display the current Python virtual environment, if available
if [[ "$LP_ENABLE_VIRTUALENV,$VIRTUAL_ENV" = 1,?* ]] ; then
LP_VENV=" [${LP_COLOR_VIRTUALENV}${VIRTUAL_ENV##*/}${NO_COL}]"
else
LP_VENV=
fi
# Display the current software collections enabled, if available
if [[ "$LP_ENABLE_SCLS,$X_SCLS" = 1,?* ]] ; then
LP_SCLS=" [${LP_COLOR_VIRTUALENV}${X_SCLS%"${X_SCLS##*[![:space:]]}"}${NO_COL}]"
else
LP_SCLS=
fi
LP_RUNTIME=$(_lp_sl "$(_lp_runtime)")
# if change of working directory
@ -1603,6 +1605,10 @@ _lp_set_prompt()
LP_VCS="$(_lp_git_branch_color)"
LP_VCS_TYPE="git"
if [[ -n "$LP_VCS" ]]; then
# If this is a vcsh repository
if [[ -n "$VCSH_DIRECTORY" ]]; then
LP_VCS_TYPE="git-vcsh"
fi
# If this is a git-svn repository
if [[ -d "$(\git rev-parse --git-dir 2>/dev/null)/svn" ]]; then
LP_VCS_TYPE="git-svn"
@ -1640,7 +1646,7 @@ _lp_set_prompt()
fi
# end of the prompt line: double spaces
LP_MARK="$(_lp_sb "$(_lp_smart_mark $LP_VCS_TYPE)")"
LP_MARK="$(_lp_sr "$(_lp_smart_mark $LP_VCS_TYPE)")"
# The color is different if user is root
LP_PWD="${LP_COLOR_PATH}${LP_PWD}${NO_COL}"
@ -1670,7 +1676,7 @@ _lp_set_prompt()
# add user, host and permissions colon
PS1="${PS1}${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_PERM}"
PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}"
PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_SCLS}${LP_VENV}${LP_PROXY}"
# Add VCS infos
# If root, the info has not been collected unless LP_ENABLE_VCS_ROOT
@ -1705,15 +1711,17 @@ prompt_tag()
prompt_on()
{
# if liquidprompt has not been already set
if [[ -z "$LP_LIQUIDPROMPT" ]] ; then
if [[ -z "$LP_OLD_PS1" ]] ; then
LP_OLD_PS1="$PS1"
if $_LP_SHELL_bash; then
LP_OLD_PROMPT_COMMAND="$PROMPT_COMMAND"
LP_OLD_SHOPT="$(shopt -p promptvars)"
else # zsh
LP_OLD_PROMPT_COMMAND="$precmd"
LP_OLD_PROMPT_COMMAND="$(whence -f precmd)"
fi
fi
if $_LP_SHELL_bash; then
shopt -s promptvars
PROMPT_COMMAND=_lp_set_prompt
[[ "$LP_DEBUG_TIME" == 1 ]] && PROMPT_COMMAND="time $PROMPT_COMMAND"
else # zsh
@ -1729,10 +1737,6 @@ prompt_on()
}
#fi
fi
# Keep in mind that LP has been sourced
# (to avoid recursive prompt command).
LP_LIQUIDPROMPT=1
}
# Come back to the old prompt
@ -1740,9 +1744,11 @@ prompt_off()
{
PS1=$LP_OLD_PS1
if $_LP_SHELL_bash; then
eval "$LP_OLD_SHOPT"
PROMPT_COMMAND="$LP_OLD_PROMPT_COMMAND"
else # zsh
precmd="$LP_OLD_PROMPT_COMMAND"
precmd() { : ; }
eval "$LP_OLD_PROMPT_COMMAND"
fi
}
@ -1751,9 +1757,11 @@ prompt_OFF()
{
PS1="\$ "
if $_LP_SHELL_bash; then
shopt -u promptvars
PROMPT_COMMAND="$LP_OLD_PROMPT_COMMAND"
else # zsh
precmd="$LP_OLD_PROMPT_COMMAND"
precmd() { : ; }
eval "$LP_OLD_PROMPT_COMMAND"
fi
}

View File

@ -5,8 +5,8 @@
# If you want to use different themes and features,
# you can load the corresponding files here:
#source ~/code/liquidprompt/nojhan.theme
#LP_PS1_FILE="~/code/liquidprompt/nojhan.ps1"
#source ~/.config/liquidprompt/nojhan.theme
#LP_PS1_FILE="~/.config/liquidprompt/nojhan.ps1"
#############
# BEHAVIOUR #
@ -33,7 +33,7 @@ LP_PATH_LENGTH=35
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 localy connected)
# Defaults to 0 (do not display hostname when locally connected)
# set to 1 if you want to always see the hostname
LP_HOSTNAME_ALWAYS=0
@ -111,6 +111,10 @@ LP_RUNTIME_THRESHOLD=2
# Recommended value is 1
LP_ENABLE_VIRTUALENV=1
# Display the enabled software collections, if any
# Recommended value is 1
LP_ENABLE_SCLS=1
# Show average system temperature
LP_ENABLE_TEMP=1

View File

@ -108,7 +108,13 @@ nproc()
acpi()
{
echo "fake acpi $@" 1>&2
echo 'Battery 0: Discharging, 55%, 01:39:34 remaining'
if [[ "x$1" == --battery ]]; then
echo 'Battery 0: Discharging, 55%, 01:39:34 remaining'
elif [[ "x$1" == -t ]]; then
echo 'Thermal 0: ok, 36.0 degrees C'
else
return 1
fi
}