]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
Merge branch 'os'
authorSimon Ruderich <simon@ruderich.org>
Sat, 2 Jun 2018 11:40:59 +0000 (13:40 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sat, 2 Jun 2018 11:40:59 +0000 (13:40 +0200)
140 files changed:
.gitmodules [new file with mode: 0644]
COPYING [new file with mode: 0644]
Makefile [new file with mode: 0644]
README [new file with mode: 0644]
archive.sh [new file with mode: 0755]
lib.m4 [new file with mode: 0644]
lib.sh [new file with mode: 0644]
setup.sh [new file with mode: 0755]
shell/.gitignore [new file with mode: 0644]
shell/Makefile [new file with mode: 0644]
shell/bash/logout [new file with mode: 0644]
shell/bash/profile [new file with mode: 0644]
shell/bash/rc [new file with mode: 0644]
shell/bin/README [new file with mode: 0644]
shell/bin/battery.pl [new file with mode: 0755]
shell/bin/calc [new file with mode: 0755]
shell/bin/chronic [new file with mode: 0755]
shell/bin/chronic-log [new file with mode: 0755]
shell/bin/mv-p [new file with mode: 0755]
shell/bin/notify.py [new file with mode: 0755]
shell/bin/print-constant.pl [new file with mode: 0755]
shell/bin/remove-continuation.pl [new file with mode: 0755]
shell/bin/rsleep [new file with mode: 0755]
shell/bin/sc [new file with mode: 0755]
shell/bin/slocate [new file with mode: 0755]
shell/bin/srandom-order [new file with mode: 0755]
shell/bin/srsync [new file with mode: 0755]
shell/bin/srsync-incremental [new file with mode: 0755]
shell/bin/supdatedb [new file with mode: 0755]
shell/bin/svalgrind [new file with mode: 0755]
shell/bin/temperature.pl [new file with mode: 0755]
shell/colordiffrc [new file with mode: 0644]
shell/crontab.d/Makefile [new file with mode: 0644]
shell/crontab.d/README [new file with mode: 0644]
shell/crontab.d/jobs [new file with mode: 0644]
shell/crontab.d/jobs.daily/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.daily/prune-logs [new file with mode: 0755]
shell/crontab.d/jobs.hourly/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.hourly6/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.hourly8/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.minutely/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.monthly/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.reboot/.gitignore [new file with mode: 0644]
shell/crontab.d/jobs.weekly/.gitignore [new file with mode: 0644]
shell/crontab.d/setup.sh [new file with mode: 0755]
shell/csh/rc [new file with mode: 0644]
shell/digrc.in [new file with mode: 0644]
shell/haskeline [new file with mode: 0644]
shell/htoprc.in [new file with mode: 0644]
shell/inputrc [new file with mode: 0644]
shell/lessfilter [new file with mode: 0755]
shell/lesskey [new file with mode: 0644]
shell/reminders.in [new file with mode: 0644]
shell/screenrc.in [new file with mode: 0644]
shell/setup.sh [new file with mode: 0755]
shell/shell/aliases.in [new file with mode: 0644]
shell/shell/bin [new symlink]
shell/shell/dircolors.in [new file with mode: 0644]
shell/shell/env [new file with mode: 0644]
shell/shell/functions [new file with mode: 0644]
shell/shell/logout [new file with mode: 0644]
shell/shell/rc [new file with mode: 0644]
shell/ssh_config [new file with mode: 0644]
shell/sshd_config [new file with mode: 0644]
shell/terminfo/README [new file with mode: 0644]
shell/terminfo/s/screen-it-256color [new file with mode: 0644]
shell/tmux-window.pl [new file with mode: 0644]
shell/tmux.conf.in [new file with mode: 0644]
shell/zsh/env [new file with mode: 0644]
shell/zsh/functions/_systemctl [new file with mode: 0644]
shell/zsh/functions/extract [new file with mode: 0644]
shell/zsh/logout [new file with mode: 0644]
shell/zsh/rc [new file with mode: 0644]
vcs/.gitignore [new file with mode: 0644]
vcs/Makefile [new file with mode: 0644]
vcs/bin/tig.pl [new file with mode: 0755]
vcs/cvsrc.in [new file with mode: 0644]
vcs/gitattributes [new file with mode: 0644]
vcs/gitconfig.in [new file with mode: 0644]
vcs/hgrc [new file with mode: 0644]
vcs/setup.sh [new file with mode: 0755]
vcs/t/expected-empty.txt [new file with mode: 0644]
vcs/t/expected-nonspaces.txt [new file with mode: 0644]
vcs/t/expected-word-nonword.txt [new file with mode: 0644]
vcs/t/expected-words-nonword.txt [new file with mode: 0644]
vcs/t/expected-words-nonwords-spaces.txt [new file with mode: 0644]
vcs/t/expected-words-nonwords.txt [new file with mode: 0644]
vcs/t/expected-words-nonwordspaces-spaces.txt [new file with mode: 0644]
vcs/t/expected-words-nonwordspaces.txt [new file with mode: 0644]
vcs/t/test.sh [new file with mode: 0755]
vcs/tigrc [new file with mode: 0644]
vcs/tigrc.old [new file with mode: 0644]
vim/.gitignore [new file with mode: 0644]
vim/Makefile [new file with mode: 0644]
vim/crontab [new file with mode: 0644]
vim/gvimrc [new file with mode: 0644]
vim/setup.sh [new file with mode: 0755]
vim/term2gui.pl [new file with mode: 0755]
vim/vim/after/ftplugin/mail.vim [new file with mode: 0644]
vim/vim/after/ftplugin/php.vim [new file with mode: 0644]
vim/vim/after/syntax/apache.vim [new file with mode: 0644]
vim/vim/after/syntax/c.vim [new file with mode: 0644]
vim/vim/after/syntax/crontab.vim [new file with mode: 0644]
vim/vim/after/syntax/diff.vim [new file with mode: 0644]
vim/vim/after/syntax/gitcommit.vim [new file with mode: 0644]
vim/vim/after/syntax/perl.vim [new file with mode: 0644]
vim/vim/after/syntax/vim.vim [new file with mode: 0644]
vim/vim/autoload/pathogen.vim [new file with mode: 0644]
vim/vim/bundle/ctrlp [new submodule]
vim/vim/bundle/deb/autoload/deb.vim [new file with mode: 0644]
vim/vim/bundle/deb/plugin/debPlugin.vim [new file with mode: 0644]
vim/vim/bundle/deb/syntax/deb.vim [new file with mode: 0644]
vim/vim/bundle/fswitch [new submodule]
vim/vim/bundle/gundo [new submodule]
vim/vim/bundle/matchit/doc/matchit.txt [new file with mode: 0644]
vim/vim/bundle/matchit/plugin/matchit.vim [new file with mode: 0644]
vim/vim/bundle/nerdcommenter [new submodule]
vim/vim/bundle/repeat [new submodule]
vim/vim/bundle/surround [new submodule]
vim/vim/bundle/xptemplate [new submodule]
vim/vim/colors/simon.vim [new file with mode: 0644]
vim/vim/ftdetect/asciidoc_filetype.vim [new file with mode: 0644]
vim/vim/ftdetect/vimperator.vim [new file with mode: 0644]
vim/vim/ftplugin/_common/personal.xpt.vim [new file with mode: 0644]
vim/vim/ftplugin/c/c.xpt.vim [new file with mode: 0644]
vim/vim/ftplugin/java/java.xpt.vim [new file with mode: 0644]
vim/vim/ftplugin/perl/perl.xpt.vim [new file with mode: 0644]
vim/vim/ftplugin/tex/tex.xpt.vim [new file with mode: 0644]
vim/vim/ftplugin/vhdl/vhdl.xpt.vim [new file with mode: 0644]
vim/vim/plugin/gnupg.vim [new file with mode: 0644]
vim/vim/plugin/matrix.vim [new file with mode: 0644]
vim/vim/plugin/securemodelines.vim [new file with mode: 0644]
vim/vim/syntax/asciidoc.vim [new file with mode: 0644]
vim/vim/syntax/getmailrc.vim [new file with mode: 0644]
vim/vim/syntax/msmtp.vim [new file with mode: 0644]
vim/vim/syntax/perl.vim [new file with mode: 0644]
vim/vim/syntax/python.vim [new file with mode: 0644]
vim/vim/syntax/tmux.vim [new file with mode: 0644]
vim/vim/syntax/vimperator.vim [new file with mode: 0644]
vim/vimrc [new file with mode: 0644]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..144dbb4
--- /dev/null
@@ -0,0 +1,21 @@
+[submodule "vim/vim/bundle/ctrlp"]
+       path = vim/vim/bundle/ctrlp
+       url = https://github.com/kien/ctrlp.vim.git
+[submodule "vim/vim/bundle/fswitch"]
+       path = vim/vim/bundle/fswitch
+       url = https://github.com/derekwyatt/vim-fswitch.git
+[submodule "vim/vim/bundle/gundo"]
+       path = vim/vim/bundle/gundo
+       url = https://github.com/sjl/gundo.vim.git
+[submodule "vim/vim/bundle/nerdcommenter"]
+       path = vim/vim/bundle/nerdcommenter
+       url = https://github.com/scrooloose/nerdcommenter.git
+[submodule "vim/vim/bundle/surround"]
+       path = vim/vim/bundle/surround
+       url = https://github.com/tpope/vim-surround.git
+[submodule "vim/vim/bundle/repeat"]
+       path = vim/vim/bundle/repeat
+       url = https://github.com/tpope/vim-repeat.git
+[submodule "vim/vim/bundle/xptemplate"]
+       path = vim/vim/bundle/xptemplate
+       url = https://github.com/drmingdrmer/xptemplate
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 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 General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is 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.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  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.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  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 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. Use with the GNU Affero General Public License.
+
+  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 Affero 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 special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 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 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 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 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 General Public License for more details.
+
+    You should have received a copy of the GNU 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 the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  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 GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..23d5991
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+all:
+       @./setup.sh
+
+.PHONY: all
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..d94ea97
--- /dev/null
+++ b/README
@@ -0,0 +1,11 @@
+README
+======
+
+Git repository to store my configuration, designed to by cloned to
+`~/.config/dotfiles`. `~/.config` is not used to allow a separate directory
+hierarchy than just the program names which is custom for `~/.config`.
+
+NOTE: This repository must contain only public data as it will be stored on
+many hosts!
+
+// vim: ft=asciidoc
diff --git a/archive.sh b/archive.sh
new file mode 100755 (executable)
index 0000000..26a0e8d
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Create an archive of my configuration file which can be uploaded on a
+# server.
+#
+# Usage: ./archive.sh
+
+# Copyright (C) 2010-2013  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+git_clone() {
+    git clone "$1" "$2" >/dev/null
+    ( cd "$2" && git remote rm origin && git gc )
+}
+
+
+# Don't overwrite an existing file/directory.
+if test -e tmp; then
+    echo 'tmp/ already exists!'
+    exit 1
+fi
+
+git_clone . tmp/dotfiles
+for name in browser shell vcs vim x11; do
+    test -d $name || continue
+
+    echo "cloning $name to tmp/"
+    git_clone $name tmp/dotfiles/$name
+done
+
+archive=dotfiles.tar.gz
+echo "creating $archive"
+tar cf tmp/$archive -C tmp -z dotfiles
+echo "moving $archive to ."
+mv tmp/$archive .
+
+rm -rf tmp
diff --git a/lib.m4 b/lib.m4
new file mode 100644 (file)
index 0000000..2f008e4
--- /dev/null
+++ b/lib.m4
@@ -0,0 +1,25 @@
+dnl Contains additional macros for m4.
+dnl
+dnl The following macros are defined: IF and FI. Example:
+dnl     IF(OS, debian)
+dnl         ...
+dnl     FI
+dnl
+dnl Copyright (C) 2009-2013  Simon Ruderich
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
+dnl
+define(`IF', `ifelse(`$1', `$2',dnl')dnl
+define(`FI', `)dnl')dnl
diff --git a/lib.sh b/lib.sh
new file mode 100644 (file)
index 0000000..70be68d
--- /dev/null
+++ b/lib.sh
@@ -0,0 +1,219 @@
+# Setup functions and settings used in subdirectories.
+#
+# Their setup.sh script sources this file.
+
+# Copyright (C) 2009-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# csh gives the error "Unknown colorls variable `su'." when used with newer
+# options supported by Zsh or GNU ls.
+unset LS_COLORS
+
+
+# Check if the given program is installed. `type` is portable, `which` is not.
+installed() {
+    type "$1" >/dev/null 2>&1
+}
+# Get the path of the given program. Thanks to Gilles on [1] (read on
+# 2013-03-10) for the PATH-walking idea. `which` is not portable and `type`
+# has no well-formed output format.
+#
+# [1]: http://unix.stackexchange.com/questions/4988/how-do-i-test-to-see-if-an-application-exists-in-path/4991
+installed_path() {
+    test -z "$1" && return 1
+
+    # Keep IFS change local.
+    (
+        IFS=:
+        # Walk PATH.
+        for directory in $PATH; do
+            if test -x "$directory/$1"; then
+                printf '%s\n' "$directory/$1"
+                return 0
+            fi
+        done
+
+        return 1
+    )
+}
+
+# Usage: cmd_i <cmd> ... <file>
+#
+# Run <cmd> with all arguments (including the last file) and write the result
+# to the temporary file <file>.tmp and then rename that file to <file>. This
+# can't be done in-place (e.g. cmd <file >file) because it truncates the file.
+cmd_i() {
+    # Get last argument.
+    last=
+    for x; do
+        last="$x"
+    done
+
+    "$@" >"$last".tmp
+    mv "$last".tmp "$last"
+}
+
+# Usage: sed_i ... <file>
+#
+# sed -i is not compatible due to different implementations. See cmd_i.
+sed_i() {
+    cmd_i sed "$@"
+}
+grep_i() {
+    cmd_i grep "$@"
+}
+
+# Usage: perl_line_filter <cmd> ...
+#
+# Run the perl command cmd on each line before printing it.
+perl_line_filter() {
+    cmd="$1"
+    shift
+
+    # Can't use -pe because it uses <> which treats the arguments as files.
+    perl -e "use strict; use warnings; while (<STDIN>) { $cmd; print; }" "$@"
+}
+
+# Usage: simple_cpp <FIRST> <SECOND> .. -- <replacement-for-first> ...
+#
+# Replaces each FIRST (on word boundaries) with <replacement-for-first> like a
+# simple cpp replacement.
+simple_cpp() {
+    cmd='my $i = 0;'
+
+    for x; do
+        shift
+
+        if test x"$x" = x--; then
+            break
+        fi
+
+        cmd="$cmd s/\b$x\b/\$ARGV[\$i]/g; \$i++;"
+    done
+
+    perl_line_filter "$cmd" -- "$@"
+}
+
+# Print the current OS. The following OS are supported at the moment:
+#
+# - Debian (debian)
+# - Gentoo (gentoo)
+# - Mac OS X (darwin)
+# - Solaris/OpenSolaris (sun)
+# - FreeBSD (freebsd)
+#
+# If an unsupported OS is used an error is printed.
+os() {
+    if test -f /etc/debian_version; then
+        echo debian
+    elif test -f /etc/gentoo-release; then
+        echo gentoo
+    elif test x`uname` = xDarwin; then
+        echo darwin
+    elif test x`uname` = xSunOS; then
+        echo sun
+    elif test x`uname` = xFreeBSD; then
+        echo freebsd
+    else
+        echo 'unsupported OS!' >&2
+        return 1
+    fi
+}
+
+# Creates a symbolic link for file $1 in dirname of $2 with name of basename
+# $2.
+#
+# `./link.sh example ~/.examplerc` creates a symbolic link to example
+# (wherever it is located) in ~/ named .examplerc.
+link() {
+    local pwd base source target >/dev/null 2>&1 || true
+
+    # Get all necessary paths.
+    pwd=`pwd`
+    base=`printf '%s' "$2" | sed "s|\~|$HOME|"` # expand ~, some sh don't do it
+    base=`dirname "$base"`
+    source=`printf '%s' "$pwd/$1" | sed "s|$base/||"`
+    target=`basename "$2"`
+
+    # Go to the directory where the link is going to be created.
+    cd "$base" || return 1
+
+    # Abort if the target file exists and is no symbolic link. Prevents
+    # overwriting real files.
+    if test -e "$target" && test ! -h "$target"; then
+        printf "link(): target '%s' exists already and is no symbolic link!\n" \
+               "$target" >&2
+        exit 1
+    fi
+
+    # Make sure the source exists.
+    if test ! -e "$source"; then
+        printf "link(): source '%s' doesn't exist!\n" "$source" >&2
+        exit 1
+    fi
+
+    # Create the new symbolic link; remove the old one if necessary.
+    printf "link(): linking '%s' to '%s'\n" "$source" "$target"
+    rm -f "$target"
+    ln -s "$source" "$target"
+
+    # Go back to the directory where we were before.
+    cd "$pwd"
+}
+
+# Generate a file from a source file using a given command. A warning not to
+# edit it is automatically added to the created file.
+#
+# Usage: generate <file> <extension> <cmd..>
+#
+# If an empty extension is provided, the file is modified in-place (through a
+# temporary file).
+generate() {
+    local file      >/dev/null 2>&1 || true
+    local file_tmp  >/dev/null 2>&1 || true
+    local extension >/dev/null 2>&1 || true
+
+    # Get command and target file.
+    file="$1"
+    extension="$2"
+    shift
+    shift
+
+    if test -z "$extension"; then
+        file_tmp="$file.tmp"
+    else
+        # We only need this message if we generate a new file.
+        printf "%s: generating from '%s' (%s)\n" \
+            "$file" "$file$extension" "$1"
+
+        echo '###################################'  >"$file"
+        echo '# WARNING! DO NOT EDIT THIS FILE! #' >>"$file"
+        echo '###################################' >>"$file"
+        echo >>"$file"
+        printf "# It was generated from '%s' on %s.\n" \
+            "$file$extension" "`date`" >>"$file"
+        echo >>"$file"
+
+        file_tmp="$file"
+    fi
+
+    # Generate $file from $file$extension using the given command.
+    "$@" <"$file$extension" >>"$file_tmp"
+
+    if test -z "$extension"; then
+        mv "$file_tmp" "$file"
+    fi
+}
diff --git a/setup.sh b/setup.sh
new file mode 100755 (executable)
index 0000000..d2a3815
--- /dev/null
+++ b/setup.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Runs setup.sh in all configuration directories. Must be run in the main
+# configuration directory.
+
+# Copyright (C) 2009-2018  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+for path in */setup.sh; do
+    # Skip non executable setup.sh files as an easy way to deactivate one.
+    test ! -x "$path" && continue
+
+    project=`printf '%s' "$path" | sed 's|/setup.sh$||'`
+
+    printf 'running setup.sh in "%s"\n' "$project"
+    ( cd "$project" && ./setup.sh >/dev/null ) || {
+        printf '%s/setup.sh failed\n' "$project" >&2
+        exit 1
+    }
+done
diff --git a/shell/.gitignore b/shell/.gitignore
new file mode 100644 (file)
index 0000000..c08e6d5
--- /dev/null
@@ -0,0 +1,17 @@
+# Ignore generated files.
+/digrc
+/htoprc
+/screenrc
+/shell/aliases
+/shell/dircolors
+/tmux.conf
+/tmux-window1.conf
+/tmux-window2.conf
+# Ignore temporary files.
+/lesshistory
+/zsh/cache
+/zsh/history*
+# Ignore unimportant files.
+/crontab.d/crontab.dotfiles-vim
+/crontab.d/crontab.jobs
+/zsh/libcoloredstderr.so
diff --git a/shell/Makefile b/shell/Makefile
new file mode 100644 (file)
index 0000000..23d5991
--- /dev/null
@@ -0,0 +1,4 @@
+all:
+       @./setup.sh
+
+.PHONY: all
diff --git a/shell/bash/logout b/shell/bash/logout
new file mode 100644 (file)
index 0000000..12f1e5d
--- /dev/null
@@ -0,0 +1,21 @@
+# Bash logout file.
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+source_config ~/.shell/logout
+
+# vim: ft=sh
diff --git a/shell/bash/profile b/shell/bash/profile
new file mode 100644 (file)
index 0000000..db373e9
--- /dev/null
@@ -0,0 +1,23 @@
+# Bash login configuration file.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+if [[ -f ~/.bashrc ]]; then
+    . ~/.bashrc
+fi
+
+# vim: ft=sh
diff --git a/shell/bash/rc b/shell/bash/rc
new file mode 100644 (file)
index 0000000..d876fe9
--- /dev/null
@@ -0,0 +1,46 @@
+# Main bash configuration file.
+#
+# Is sourced by all interactive bash shells and other shells like scp or rcp.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+. ~/.shell/functions
+
+source_config ~/.shell/env
+
+
+# Check if this is an interactive shell. Abort if not to prevent problems with
+# scp and rcp. Taken from default Debian bashrc. Thanks.
+if [[ $- != *i* ]]; then
+    return
+fi
+
+
+# Set the prompt; hostname and current working directory are displayed.
+# Hostname is displayed in bold green, current directory in yellow.
+PS1='\[\033[01;32m\]\h\[\033[00m\]:\[\033[33m\]\w\[\033[00m\] \$ '
+
+# Use Vi(m) style readline mappings in bash.
+set -o vi
+
+
+source_config ~/.shell/aliases
+source_config ~/.shell/rc
+
+source_config ~/.bash/rc.local
+
+# vim: ft=sh
diff --git a/shell/bin/README b/shell/bin/README
new file mode 100644 (file)
index 0000000..ad0164a
--- /dev/null
@@ -0,0 +1,7 @@
+README
+======
+
+Contains shell related programs useful on all computers. Wrapper scripts are
+prefixed with "s". All programs are licensed under GPL v3+.
+
+Available through a symbolic link in shell: ~/.shell/bin/
diff --git a/shell/bin/battery.pl b/shell/bin/battery.pl
new file mode 100755 (executable)
index 0000000..c7e812e
--- /dev/null
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+if (scalar @ARGV != 1 and (scalar @ARGV != 2 or not $ARGV[0] =~ /-[st]/)) {
+    print STDERR "Usage: $0 [-s | -t] <path/to/device>\n";
+    print STDERR "\n";
+    print STDERR "Normally this is /sys/class/power_supply/BAT*.\n";
+    exit 1;
+}
+if (scalar @ARGV == 1) {
+    @ARGV = ('', $ARGV[0]);
+}
+
+my $path = "$ARGV[1]/uevent";
+
+# No battery available.
+if (not -e $path) {
+    print STDERR "'$path' not found.\n";
+    exit 1;
+}
+
+my $screen_mode = ($ARGV[0] eq '-s');
+my $tmux_mode   = ($ARGV[0] eq '-t');
+
+my %battery;
+
+open my $file, '<', $path or die $!;
+while (<$file>) {
+    /^POWER_SUPPLY_([A-Z_]+)=(.+)$/;
+    $battery{$1} = $2;
+}
+close $file or die $!;
+
+# New names ...
+if (defined $battery{ENERGY_NOW}) {
+    $battery{CHARGE_NOW}  = $battery{ENERGY_NOW};
+    $battery{CHARGE_FULL} = $battery{ENERGY_FULL};
+}
+
+my $charge = int($battery{CHARGE_NOW} / $battery{CHARGE_FULL} * 100);
+my $charging = '';
+if ($battery{STATUS} eq 'Charging' or $battery{STATUS} eq 'Full') {
+    $charging = '^';
+}
+
+# GNU screen mode with colors: 0-20 red, 20-40 yellow, 40-100 green.
+if ($screen_mode) {
+    my $color;
+    if ($charge < 20) {
+        $color = 'b r';
+    } elsif ($charge < 40) {
+        $color = 'b y';
+    } else {
+        $color = 'b g';
+    }
+
+    print "\005{+$color}$charge%\005{-}$charging\n";
+
+# Same in tmux mode.
+} elsif ($tmux_mode) {
+    my $color;
+    if ($charge < 20) {
+        $color = 'red';
+    } elsif ($charge < 40) {
+        $color = 'yellow';
+    } else {
+        $color = 'green';
+    }
+
+    print "#[fg=$color,bold]$charge%#[default]$charging\n";
+
+# Plain text output.
+} else {
+    print "$charge%$charging\n";
+}
diff --git a/shell/bin/calc b/shell/bin/calc
new file mode 100755 (executable)
index 0000000..ea3cbd3
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+exec python -i -c '
+
+# Math functions.
+from math import *
+
+def ld(x):
+    return log(x)/log(2)
+def lg(x):
+    return log10(x)
+
+def binom(n,k):
+    return reduce(lambda a,b: a*(n-b)/(b+1),xrange(k),1)
+
+# Convert number to scientific notation (e.g. 5e6).
+def s(x):
+    print "%e" % x
+
+
+# Time/Date functions.
+import time
+
+# Convert time in seconds since epoch to readable string.
+def stime(seconds):
+    print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds))
+
+
+print "Welcome to the ultimate calculator."'
+
+# vim: ft=python
diff --git a/shell/bin/chronic b/shell/bin/chronic
new file mode 100755 (executable)
index 0000000..a9fa47b
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+chronic - runs a command quietly unless it fails
+
+=head1 SYNOPSIS
+
+chronic COMMAND...
+
+=head1 DESCRIPTION
+
+chronic runs a command, and arranges for its standard out and standard
+error to only be displayed if the command fails (exits nonzero or crashes).
+If the command succeeds, any extraneous output will be hidden.
+
+A common use for chronic is for running a cron job. Rather than
+trying to keep the command quiet, and having to deal with mails containing
+accidental output when it succeeds, and not verbose enough output when it
+fails, you can just run it verbosely always, and use chronic to hide
+the successful output.
+
+       0 1 * * * chronic backup # instead of backup >/dev/null 2>&1
+
+=head1 AUTHOR
+
+Copyright 2010 by Joey Hess <joey@kitenet.net>
+
+Original concept and "chronic" name by Chuck Houpt.
+
+Licensed under the GNU GPL version 2 or higher.
+
+=cut
+
+use warnings;
+use strict;
+use IPC::Run qw( start pump finish timeout );
+
+if (! @ARGV) {
+       die "usage: chronic [-l LOGFILE] COMMAND...\n";
+}
+
+my $logfile;
+if (@ARGV >= 3 and $ARGV[0] eq '-l') {
+       $logfile = $ARGV[1];
+       shift @ARGV;
+       shift @ARGV;
+}
+
+my ($out, $err);
+my $h = IPC::Run::start \@ARGV, \*STDIN, \$out, \$err;
+$h->finish;
+my $ret=$h->full_result;
+
+if (defined $logfile) {
+       open my $fh, '>', $logfile
+               or showout_and_die("failed to open logfile '$logfile'");
+       print $fh $err; # stderr is more interesting, show it first
+       print $fh $out;
+       close $fh
+               or showout_and_die("failed to close logfile '$logfile'");
+}
+
+if ($ret >> 8) { # child failed
+       showout();
+       exit ($ret >> 8);
+}
+elsif ($ret != 0) { # child killed by signal
+       showout();
+       exit 1;
+}
+else {
+       exit 0;
+}
+
+sub showout {
+       print STDOUT $out;
+       print STDERR $err;
+}
+sub showout_and_die {
+       my $errno = $!;
+       showout();
+       die "chronic: $_[0]: $errno\n";
+}
diff --git a/shell/bin/chronic-log b/shell/bin/chronic-log
new file mode 100755 (executable)
index 0000000..e8dc7ea
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Simple wrapper around (my) chronic which writes the log files to
+# ~/.tmp/logs/.
+
+# Copyright (C) 2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+if test $# -lt 2; then
+    echo "Usage: $0 <logfile> <cmd> <args>.." >&2
+    exit 1
+fi
+
+
+name="$1"
+shift
+
+today=`date '+%Y-%m-%d'`
+now=`date '+%H:%M:%S'`
+
+logdir="$HOME/.tmp/logs/$today"
+mkdir -p "$logdir"
+exec chronic -l "$logdir/$name-$now" "$@"
diff --git a/shell/bin/mv-p b/shell/bin/mv-p
new file mode 100755 (executable)
index 0000000..7259d33
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# Wrapper command for `mv` which creates the target directory before moving
+# the file there.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+# Get last argument.
+for last; do
+    :
+done
+
+mkdir -p "`dirname "$last"`" \
+    && mv "$@"
diff --git a/shell/bin/notify.py b/shell/bin/notify.py
new file mode 100755 (executable)
index 0000000..3caa7d2
--- /dev/null
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+
+# notify.py is a simple notification program displaying a message on the
+# screen.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+import sys
+import locale
+
+import pygtk
+pygtk.require('2.0') # there might be a GTK 1 version installed, ignore it
+import gtk
+import pango
+import gobject
+
+
+# Pressing the mouse inside the window quits notify.
+def mouse_press_callback(widget, event):
+    gtk.main_quit()
+
+
+if __name__ == '__main__':
+    if len(sys.argv) != 2:
+        sys.stderr.write("Usage: %s <message>\n" % (sys.argv[0]))
+        sys.exit(1)
+
+    # Display configuration.
+    BOLD     = True
+    FG_COLOR = 'blue'
+    BG_COLOR = 'yellow'
+
+    # We need a popup so the window manager doesn't touch our window.
+    window = gtk.Window(gtk.WINDOW_POPUP)
+    # No window border or close/resize buttons.
+    window.set_decorated(False)
+    # In case set_decorated(False) doesn't work with the used window manager
+    # quit when the window is manually closed.
+    window.connect('delete-event', gtk.main_quit)
+    # Enable mouse click events, by default windows don't receive them.
+    window.add_events(gtk.gdk.BUTTON_PRESS_MASK)
+    window.connect('button-press-event', mouse_press_callback)
+
+    # Background color.
+    window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(BG_COLOR))
+
+    string = sys.argv[1].decode(locale.getdefaultlocale()[1])
+
+    # Colored message string.
+    label_message = gtk.Label(string)
+    label_message.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(FG_COLOR))
+    window.add(label_message)
+
+    if BOLD:
+        attributes = pango.AttrList()
+        attributes.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, end_index=-1))
+        label_message.set_attributes(attributes)
+
+    # Display at the top at full screen width.
+    screen = window.get_screen()
+    window.resize(screen.get_width(), 30)
+    window.move(0, 15)
+
+    window.show_all()
+    gtk.main()
diff --git a/shell/bin/print-constant.pl b/shell/bin/print-constant.pl
new file mode 100755 (executable)
index 0000000..f0205db
--- /dev/null
@@ -0,0 +1,258 @@
+#!/usr/bin/perl
+
+# Print values of C constants.
+
+# Copyright (C) 2012  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+use Getopt::Long ();
+use File::Temp ();
+
+our $VERSION = '0.01';
+
+
+my $option_help     = 0;
+my $option_version  = 0;
+my @option_include  = ();
+my $option_pathconf = undef;
+my $option_quiet    = 0;
+my $option_sysconf  = 0;
+my $option_type     = 'd';
+if (not Getopt::Long::GetOptions(
+            'help|h|?'     => \$option_help,
+            'version|v'    => \$option_version,
+            #
+            'include|i=s'  => \@option_include,
+            'pathconf|p=s' => \$option_pathconf,
+            'quiet|q'      => \$option_quiet,
+            'sysconf|s'    => \$option_sysconf,
+            'type|t=s'     => \$option_type,
+        )) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage(2);
+}
+if ($option_help) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage(1);
+}
+if ($option_version) {
+    print <<EOF;
+print-constant $VERSION  Copyright (C) 2012  Simon Ruderich
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+EOF
+    exit 0;
+}
+
+# We need the constant name as argument.
+if (scalar @ARGV != 1) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage(2);
+}
+
+
+my $constant = $ARGV[0];
+# Check for non-constant name inputs - also prevents running arbitrary code on
+# the machine.
+if (not $constant =~ /^[a-zA-Z0-9_]+$/) {
+    print STDERR "Invalid constant name: '$constant'!\n";
+    exit 1;
+}
+
+# Some sanity checks.
+if (not $option_type =~ /^[a-zA-Z]+$/) {
+    print STDERR "Invalid type: '$option_type'!\n";
+    exit 1;
+}
+if ($option_sysconf and defined $option_pathconf) {
+    print STDERR "--sysconf and --pathconf can't be used together!\n";
+    exit 1;
+}
+foreach my $include (@option_include) {
+    if (not $include =~ m{^[a-zA-Z0-9./_-]+$}) {
+        print STDERR "Invalid include: '$include'!\n";
+        exit 1;
+    }
+}
+
+my $constant_display = $constant;
+# Pass the constant to sysconf()/pathconf() instead of using it directly.
+if ($option_sysconf) {
+    $constant = "sysconf($constant)";
+    $constant_display = $constant;
+} elsif (defined $option_pathconf) {
+    $constant_display = "pathconf(\"$option_pathconf\", $constant)";
+    # Use the current directory to prevent escape problems for the path, see
+    # below.
+    $constant = "pathconf(\".\", $constant)";
+}
+
+
+# Use "limits.h" and "unistd.h" as default include - but only if the user
+# specified no other includes, in case it conflicts with "limits.h".
+if (scalar @option_include == 0) {
+    push @option_include, 'limits.h';
+    push @option_include, 'unistd.h';
+}
+
+
+# Temporary directory where the following C program which prints the constant
+# is built.
+my $tempdir = File::Temp::tempdir(CLEANUP => 1) or die $!;
+chdir $tempdir or die $!;
+
+# Write the C file which prints the constant value.
+my $c_template = <<'EOF';
+#include <stdio.h>
+#include <stdlib.h>
+%s
+
+int main(int argc, char **argv) {
+    printf("%s\n", %s);
+
+    return EXIT_SUCCESS;
+}
+EOF
+open my $fh, '>', 'constant.c' or die $!;
+printf $fh $c_template,
+           join("\n", map { "#include <$_>" } @option_include),
+           '%' . $option_type,
+           $constant;
+close $fh or die $!;
+
+# Compile the constant C file.
+my @args = ('cc', '-o', 'constant', 'constant.c');
+if (system(@args) != 0) {
+    print STDERR "Compilation failure (message above).\n";
+
+    chdir; # see below
+    exit 1;
+}
+
+# pathconf() needs a path, we use the current directory - therefore we have to
+# chdir to the given path. This prevents escape problems with the path.
+if (defined $option_pathconf) {
+    chdir $option_pathconf;
+}
+
+my $value = `$tempdir/constant`;
+
+if ($option_quiet) {
+    print $value;
+} else {
+    print "$constant_display: $value";
+}
+
+# Change the working directory or File::Temp can't remove our temporary
+# directory.
+chdir;
+
+
+__END__
+
+=head1 NAME
+
+print-constant - print values of C constants
+
+=head1 SYNOPSIS
+
+B<print-constant> [I<options>] I<CONSTANT_NAME>
+
+=head1 DESCRIPTION
+
+print-constant prints the values of C constants. Useful to find out certain
+system constants without having to write a small C program to print them.
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<-i> I<include>, B<--include> I<include>
+
+Use I<include> as include file. Adds C<#include E<lt>includeE<gt>> to the
+beginning of the C file used to print the constant. By default C<limits.h> and
+C<unistd.h> are used as headers. If this option is specified I<no> default
+includes are used. Can be specified multiple times.
+
+=item B<-p> I<path>, B<--pathconf> I<path>
+
+Pass the constant to pathconf(3) and print the result. I<path> is the first
+argument for pathconf(3). Conflicts with B<--sysconf>.
+
+=item B<-q>, B<--quiet>
+
+Display only the constant's value.
+
+=item B<-s>, B<--sysconf>
+
+Pass the constant to sysconf(3) and print the result. Conflicts with
+B<--pathconf>.
+
+=item B<-t> I<type>, B<--type> I<type>
+
+Use I<type> as type of the constant, used in printf(3). By default C<d> is
+used.
+
+=item B<-h>, B<-?>, B<--help>
+
+Print available options.
+
+=item B<-v>, B<--version>
+
+Print version number and license.
+
+=back
+
+=head1 AUTHOR
+
+Simon Ruderich, E<lt>simon@ruderich.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2012 by Simon Ruderich
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+=head1 SEE ALSO
+
+L<sysconf(3)>, L<pathconf(3)>
+
+=cut
diff --git a/shell/bin/remove-continuation.pl b/shell/bin/remove-continuation.pl
new file mode 100755 (executable)
index 0000000..3deb7d7
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+# Remove continuation lines from stdin/file. Leading whitespace on the next
+# line is removed.
+
+# Copyright (C) 2012  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+my $continuation = 0;
+while (<STDIN>) {
+    # Remove leading whitespace if the last line was a line continuation.
+    if ($continuation) {
+        s/^\s+//;
+    }
+
+    if (/^(.+?)\\$/) {
+        print $1;
+        $continuation = 1;
+    } else {
+        print $_;
+        $continuation = 0;
+    }
+}
+# Handle line continuation on the last line.
+print "\n" if $continuation;
diff --git a/shell/bin/rsleep b/shell/bin/rsleep
new file mode 100755 (executable)
index 0000000..9b953c5
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+# Sleep randomly between 0 and $ARGV[0] seconds.
+
+# Copyright (C) 2013-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+if (scalar @ARGV != 1) {
+    print STDERR "Usage: $0 <maximum sleep time in seconds>\n";
+    exit 1;
+}
+
+srand;
+sleep int rand $ARGV[0];
diff --git a/shell/bin/sc b/shell/bin/sc
new file mode 100755 (executable)
index 0000000..506e90a
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Small wrapper for systemctl which provides some shortcuts.
+
+# Copyright (C) 2015  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+
+args=( )
+found=
+for arg; do
+    # This heuristic replaces the first occurrence of a shortcut with its
+    # expansion. This is not perfect (e.g. `systemctl status s` would result
+    # in `systemctl status status`) but works even when options are used and
+    # doesn't require us to duplicate systemctl's parsing of command line
+    # arguments.
+    if [[ -z $found ]]; then
+        found=1
+        case "$arg" in
+            c)  arg=cat     ;;
+            d)  arg=disable ;;
+            e)  arg=enable  ;;
+            k)  arg=kill    ;;
+            m)  arg=mask    ;;
+            r)  arg=restart ;;
+            rl) arg=reload  ;;
+            s)  arg=status  ;;
+            sa) arg=start   ;;
+            so) arg=stop    ;;
+            u)  arg=unmask  ;;
+            # No match, try it again for the next parameter.
+            *)  found=      ;;
+        esac
+    fi
+    args+=( "$arg" )
+done
+
+set +u # empty $args causes an error, I think this is a bug in bash
+exec systemctl "${args[@]}"
diff --git a/shell/bin/slocate b/shell/bin/slocate
new file mode 100755 (executable)
index 0000000..43e1eb2
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Search only in the local `locate` database. Created with `supdatedb`.
+
+# Copyright (C) 2012-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+exec locate -d "$HOME/.tmp/locatedb" "$@"
diff --git a/shell/bin/srandom-order b/shell/bin/srandom-order
new file mode 100755 (executable)
index 0000000..45297be
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Run all files in the current directory (recursively) in a random order with
+# the given program.
+
+# Copyright (C) 2012-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+if test "$#" -eq 0; then
+    echo "Usage: $0 <program-args>.." >&2
+    exit 2
+fi
+
+find . -type f -print0 \
+    | sort --random-sort --zero-terminated \
+    | xargs -0 "$@"
diff --git a/shell/bin/srsync b/shell/bin/srsync
new file mode 100755 (executable)
index 0000000..8402bb3
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# rsync shortcut with options "everybody" needs.
+
+# Be careful when restoring /boot with --sparse, GRUB doesn't support sparse
+# files (e.g. the kernel). Therefore don't use --sparse in this case.
+
+# Copyright (C) 2011-2015  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+set -x
+
+exec rsync \
+    --verbose \
+    --itemize-changes \
+    --human-readable \
+    --archive \
+    --acls \
+    --xattrs \
+    --hard-links \
+    --sparse \
+    --numeric-ids \
+    --one-file-system \
+    "$@"
diff --git a/shell/bin/srsync-incremental b/shell/bin/srsync-incremental
new file mode 100755 (executable)
index 0000000..187e6b6
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Perform incremental backups using rsync and hardlinks.
+#
+# Thanks to http://www.sanitarium.net/golug/rsync_backups_2010.html for the
+# idea.
+
+# Copyright (C) 2011-2017  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+if test "$#" -lt 2; then
+    echo "Usage: $0 <backups-directory> <arguments to rsync>" >&2
+    echo
+    echo "Note: The target directory is the _first_ argument!" >&2
+    exit 2
+fi
+
+
+cd "$1"
+shift
+
+# Get path to last backup directory.
+dest=./
+for x in backup-*; do
+    test -d "$x" || continue
+    dest="../$x" # relative to destination directory
+done
+
+target="backup-$(date '+%Y-%m-%d-%H-%M-%S')"
+target_tmp="partial-$target"
+
+mkdir "$target_tmp"
+rsync \
+    --verbose --itemize-changes --human-readable \
+    --archive --acls --xattrs --hard-links --sparse --numeric-ids \
+    --one-file-system \
+    --link-dest="$dest" \
+    "$@" "$target_tmp" \
+|| {
+    # Try to remove the target directory without changing the exit code. In
+    # case the connection failed without transferring any files, we want to
+    # remove the empty directory.
+    code=$?
+    rmdir "$target_tmp" 2>/dev/null || true
+    exit $code
+}
+# --dry-run (-n) creates an empty directory. Remove it to prevent using it for
+# further incremental backups (which would do a full backup).
+rmdir "$target_tmp" 2>/dev/null && exit 0 || true
+
+mv "$target_tmp" "$target"
diff --git a/shell/bin/supdatedb b/shell/bin/supdatedb
new file mode 100755 (executable)
index 0000000..4f5fac0
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Generate `locate` database for my home directory only. Exclude backups and
+# other temporary files.
+
+# Copyright (C) 2012-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+exec updatedb \
+    --localpaths="$HOME" \
+    --prunepaths="$HOME/.tmp $HOME/tmp" \
+    --output="$HOME/.tmp/locatedb"
diff --git a/shell/bin/svalgrind b/shell/bin/svalgrind
new file mode 100755 (executable)
index 0000000..bcb68da
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+exec valgrind --leak-check=full --show-reachable=yes --error-exitcode=1 \
+              --track-fds=yes --quiet "$@"
diff --git a/shell/bin/temperature.pl b/shell/bin/temperature.pl
new file mode 100755 (executable)
index 0000000..42eaffe
--- /dev/null
@@ -0,0 +1,96 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+if (scalar @ARGV != 1 and (scalar @ARGV != 2 or not $ARGV[0] =~ /-[st]/)) {
+    print STDERR "Usage: $0 [-s | -t] <path/to/device>\n";
+    print STDERR "\n";
+    print STDERR "Normally this is /sys/devices/platform/*.\n";
+    exit 1;
+}
+if (scalar @ARGV == 1) {
+    @ARGV = ('', $ARGV[0]);
+}
+
+my $temperature_path = "$ARGV[1]/temp1_input";
+my $critical_path    = "$ARGV[1]/temp1_crit";
+
+# No temperature information available.
+if (not -e $temperature_path or not -e $critical_path) {
+    print STDERR "'$temperature_path' or '$critical_path' not found.\n";
+    exit 1;
+}
+
+my $screen_mode = ($ARGV[0] eq '-s');
+my $tmux_mode   = ($ARGV[0] eq '-t');
+
+my $temperature;
+my $critical;
+
+my $file;
+open $file, '<', $temperature_path or die $!;
+$temperature = <$file>;
+close $file or die $!;
+open $file, '<', $critical_path or die $!;
+$critical = <$file>;
+close $file or die $!;
+
+my $value = int($temperature / 1000);
+my $risk  = ($critical - $temperature)/$critical;
+
+$value .= "\xb0"; # degree symbol in UTF-8
+
+# GNU screen mode with colors.
+if ($screen_mode) {
+    my $color;
+    if ($risk < 0) {
+        $color = 'br r'; # bold reverse
+    } elsif ($risk < 0.1) {
+        $color = 'b r';
+    } elsif ($risk < 0.2) {
+        $color = 'b y';
+    } else {
+        $color = 'b g';
+    }
+
+    print "\005{+$color}$value\005{-}\n";
+
+# Same in tmux mode.
+} elsif ($tmux_mode) {
+    my $color;
+    my $style = 'bold';
+    if ($risk < 0) {
+        $color = 'red';
+        $style = 'reverse'; # blink doesn't work for me
+    } elsif ($risk < 0.1) {
+        $color = 'red';
+    } elsif ($risk < 0.2) {
+        $color = 'yellow';
+    } else {
+        $color = 'green';
+    }
+
+    print "#[fg=$color,$style]$value#[default]\n";
+
+# Plain text output.
+} else {
+    print "$value\n";
+}
diff --git a/shell/colordiffrc b/shell/colordiffrc
new file mode 100644 (file)
index 0000000..d8f91db
--- /dev/null
@@ -0,0 +1,24 @@
+# Colordiff configuration file.
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Custom colors for the diff output which is more similar to TextMate's output
+# (new: green, old: red).
+newtext=green
+oldtext=red
+diffstuff=magenta
+cvsstuff=yellow
diff --git a/shell/crontab.d/Makefile b/shell/crontab.d/Makefile
new file mode 100644 (file)
index 0000000..23d5991
--- /dev/null
@@ -0,0 +1,4 @@
+all:
+       @./setup.sh
+
+.PHONY: all
diff --git a/shell/crontab.d/README b/shell/crontab.d/README
new file mode 100644 (file)
index 0000000..56121ce
--- /dev/null
@@ -0,0 +1,8 @@
+README
+======
+
+`setup.sh` combines all 'crontab.*' files in this directory into a single
+crontab file and loads it with `crontab`.
+
+This replaces the current crontab! If no 'crontab.*' files were found, the
+current crontab is removed.
diff --git a/shell/crontab.d/jobs b/shell/crontab.d/jobs
new file mode 100644 (file)
index 0000000..8426b7a
--- /dev/null
@@ -0,0 +1,44 @@
+# Run jobs on regular bases. Similar to /etc/cron.*/.
+#
+# Symlink to crontab.jobs to enable it.
+
+# Copyright (C) 2013-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Include user's binaries in PATH. Expanding $HOME doesn't work with cron,
+# `setup.sh` handles that!
+PATH=$HOME/bin:$HOME/.shell/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
+# `rsleep` (random sleep) is used to reduce concurrent commands if this
+# crontab file is used by multiple users.
+
+
+# Taken from Debian's /etc/crontab from cron package 3.0pl1-124 and modified.
+# Thanks.
+17 * * * * rsleep 60;   run-parts --report .crontab.d/jobs.hourly
+25 6 * * * rsleep 1800; run-parts --report .crontab.d/jobs.daily
+47 6 * * 7 rsleep 3600; run-parts --report .crontab.d/jobs.weekly
+52 6 1 * * rsleep 3600; run-parts --report .crontab.d/jobs.monthly
+
+# Run on system startup.
+@reboot run-parts --report .crontab.d/jobs.reboot
+
+# Run every minute.
+* * * * * run-parts --report .crontab.d/jobs.minutely
+# Run every x hours.
+31 */6 * * * rsleep 600; run-parts --report .crontab.d/jobs.hourly6
+39 */8 * * * rsleep 600; run-parts --report .crontab.d/jobs.hourly8
+
+# vim: ft=crontab
diff --git a/shell/crontab.d/jobs.daily/.gitignore b/shell/crontab.d/jobs.daily/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.daily/prune-logs b/shell/crontab.d/jobs.daily/prune-logs
new file mode 100755 (executable)
index 0000000..74aa1f2
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Remove log files created by schronic which are older than two weeks.
+
+# Copyright (C) 2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+
+logdir="$HOME/.tmp/logs"
+if test ! -d "$logdir"; then
+    exit 0
+fi
+
+# Remove empty directories.
+rmdir "$logdir"/* 2>/dev/null || true
+
+exec find "$logdir/" -type f -mtime +14 -delete
diff --git a/shell/crontab.d/jobs.hourly/.gitignore b/shell/crontab.d/jobs.hourly/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.hourly6/.gitignore b/shell/crontab.d/jobs.hourly6/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.hourly8/.gitignore b/shell/crontab.d/jobs.hourly8/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.minutely/.gitignore b/shell/crontab.d/jobs.minutely/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.monthly/.gitignore b/shell/crontab.d/jobs.monthly/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.reboot/.gitignore b/shell/crontab.d/jobs.reboot/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/jobs.weekly/.gitignore b/shell/crontab.d/jobs.weekly/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/shell/crontab.d/setup.sh b/shell/crontab.d/setup.sh
new file mode 100755 (executable)
index 0000000..46ebb56
--- /dev/null
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+# Combine all crontab.* files in ~/.crontab.d/ into a single crontab file and
+# load it with `crontab`.
+#
+# An existing crontab entry not generated with this script is not overwritten.
+
+# Copyright (C) 2012-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+
+HEADER_WARNING='# WARNING! DO NOT EDIT THIS FILE! #'
+
+# Don't overwrite existing crontab entries. Not race condition free but that
+# can't be helped.
+if crontab -l >/dev/null 2>&1; then
+    if crontab -l | head -n3 | grep -F -x "$HEADER_WARNING" >/dev/null; then
+        :
+    else
+        echo 'Existing crontab entry found, please remove it manually.'
+        exit 2
+    fi
+fi
+
+
+DIRECTORY="$HOME/.crontab.d"
+if test ! -d "$DIRECTORY" || test ! -O "$DIRECTORY"; then
+    exit 1
+fi
+
+# `set -e` aborts when `mktemp` fails.
+CRONTAB=`mktemp --tmpdir="$DIRECTORY" update-crontab.XXXXXXXXXXXX`
+
+echo '###################################'  >"$CRONTAB"
+echo "$HEADER_WARNING"                     >>"$CRONTAB"
+echo '###################################' >>"$CRONTAB"
+echo >>"$CRONTAB"
+printf "# It was generated from '%s/*' on %s." \
+    "$DIRECTORY" "`LANG=C date '+%a, %d %b %Y %H:%M:%S %z'`" >>"$CRONTAB"
+
+# Enforce C sort order.
+LC_ALL=C
+
+NO_MATCHES=
+for file in "$DIRECTORY"/crontab.*; do
+    # No crontab.* files exist, abort.
+    if test ! -e "$file"; then
+        NO_MATCHES=y
+        break
+    fi
+
+    printf "Found '%s'.\n" "$file"
+
+    printf '\n\n## %s:\n' "$file" >>"$CRONTAB"
+
+    # Strip licenses, multiple empty lines and fix $HOME variables in PATH
+    # (cron doesn't expand variables).
+    START_REGEX='^# This [a-zA-Z]* is free software: you can redistribute it'
+    END_REGEX='^# along with this [a-zA-Z]*.  If not, see <[^>]*>\.'
+    <"$file" sed -e "/$START_REGEX/,/$END_REGEX/ d" \
+                 -e "/^#[ ]*$/ d" \
+                 -e "/^# Copyright (C) [0-9][0-9]* / d" \
+        | cat --squeeze-blank \
+        | sed "/^PATH/ s:\$HOME:$HOME:g" \
+        >>"$CRONTAB"
+done
+
+# Update crontab with the crontab.* files.
+if test -z "$NO_MATCHES"; then
+    echo
+    echo 'Updating crontab.'
+    crontab "$CRONTAB"
+
+# No files found, remove the existing crontab entry. Ignore errors in case no
+# crontab entry existed in the first place.
+else
+    echo 'No files found, removing old crontab (if it exists).'
+    crontab -r || true
+fi
+
+rm "$CRONTAB"
diff --git a/shell/csh/rc b/shell/csh/rc
new file mode 100644 (file)
index 0000000..0fdc66a
--- /dev/null
@@ -0,0 +1,26 @@
+# Csh configuration file.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Start Zsh in interactive login mode if available, otherwise do nothing. -l
+# is used so Zsh sources .zlogin and .zlogout.
+if ($?prompt) then
+    # csh doesn't use `type` .. yeah POSIX.
+    which zsh >/dev/null && exec zsh -l
+endif
+
+# vim: ft=csh
diff --git a/shell/digrc.in b/shell/digrc.in
new file mode 100644 (file)
index 0000000..c686042
--- /dev/null
@@ -0,0 +1,23 @@
+# Dig configuration file.
+#
+# dig doesn't support comments in ~/.digrc. They must be stripped before using
+# this file.
+
+# Copyright (C) 2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Use the search list or domain directive as defined in /etc/resolv.conf.
++search
diff --git a/shell/haskeline b/shell/haskeline
new file mode 100644 (file)
index 0000000..ecf2428
--- /dev/null
@@ -0,0 +1,39 @@
+-- Configuration file for haskeline (an incomplete readline "clone").
+
+-- Copyright (C) 2014  Simon Ruderich
+--
+-- This file is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This file 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 General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+-- Activate Vi editing mode.
+editMode: Vi
+
+-- Never ring any bell.
+bellStyle: NoBell
+
+-- Increase history size.
+maxHistorySize: Just 50000
+-- Don't add consecutive duplicate lines to the history.
+historyDuplicates: IgnoreConsecutive
+
+
+-- KEY BINDINGS
+
+-- <Up>/<Down> with the additional effect that only lines starting with the
+-- current input are matched. Very useful to recall old commands quickly -
+-- just type the first few characters.
+bind: ctrl-p meta-k
+bind: ctrl-n meta-j
+
+-- vim: ft=haskell
diff --git a/shell/htoprc.in b/shell/htoprc.in
new file mode 100644 (file)
index 0000000..194328d
--- /dev/null
@@ -0,0 +1,76 @@
+# htop configuration file.
+
+# Useful mappings:
+#
+# Use \ to limit to only matching processes (like l in mutt). _Very_ useful.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Ordered in the same way htop orders them for easy diffing.
+
+# Display the following fields (trailing whitespace for easy diffing ...):
+#
+# - PID (0)
+# - USER (48)
+# - NICE (18)
+# - M_SIZE (38): virtual memory
+# - M_RESIDENT (39): resident memory
+# - M_SHARE (40): shared memory
+# - STATE (2)
+# - PERCENT_CPU (46)
+# - PERCENT_MEM (47)
+# - TIME (49)
+# - STARTTIME (20)
+# - Command (1)
+fields=0 48 18 38 39 40 2 46 47 49 20 1 
+
+# Don't display kernel threads.
+hide_kernel_threads=1
+# But display userland threads.
+hide_userland_threads=0
+# Display thread names. The command line is displayed in the tree view as
+# parent of the threads.
+show_thread_names=1
+
+# Highlight program base name.
+highlight_base_name=1
+# Highlight megabytes in memory usage.
+highlight_megabytes=1
+# Highlight threads.
+highlight_threads=1
+
+# Display detailed CPU information, including IO-Wait.
+detailed_cpu_time=1
+
+# Display the following meters.
+#
+# left: - first part of CPU usage, bar (LeftCPUs)
+#       - memory usage, bar (Memory)
+#       - swap usage, bar (Swap)
+#       - hostname, text (Hostname)
+#
+# right: - second part of CPU usage, bar (RightCPUs)
+#        - task statistics, text (Tasks)
+#        - load average, text (LoadAverage)
+#        - uptime, text (Uptime)
+#
+left_meters=LeftCPUs Memory Swap Hostname 
+left_meter_modes=1 1 1 2 
+right_meters=RightCPUs Tasks LoadAverage Uptime 
+right_meter_modes=1 2 2 2 
+
+# vim: ft=cfg
diff --git a/shell/inputrc b/shell/inputrc
new file mode 100644 (file)
index 0000000..aa74013
--- /dev/null
@@ -0,0 +1,54 @@
+# Configuration file for readline.
+
+# Copyright (C) 2011-2015  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Only one <Tab> is necessary to get a list of all possible options.
+set show-all-if-ambiguous on
+set show-all-if-unmodified on
+
+# Always complete all items no matter how many there are.
+set completion-query-items -1
+# And make sure we use a pager for completions (this is also the default).
+set page-completions on
+
+# Add character to files denoting the type when completing file names.
+set visible-stats on
+
+# Activate Vi editing mode.
+set editing-mode vi
+
+
+# KEY BINDINGS
+
+# Insert mode.
+
+# Use jk to exit insert mode (jj is too slow to type).
+"jk": vi-movement-mode
+
+# <Up>/<Down> with the additional effect that only lines starting with the
+# current input are matched. Very useful to recall old commands quickly - just
+# type the first few characters.
+"\C-p": history-search-backward
+"\C-n": history-search-forward
+
+# Allow <C-L> in Vi normal mode to clear the screen.
+"\C-L": clear-screen
+
+# Command mode.
+set keymap vi
+
+# No bindings yet.
diff --git a/shell/lessfilter b/shell/lessfilter
new file mode 100755 (executable)
index 0000000..1403df4
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+case "$1" in
+    # Color diff files.
+    *.diff | *.patch)
+        colordiff <"$1"
+        ;;
+
+    *.nfo)
+        iconv -f latin1 -t utf-8 <"$1"
+        ;;
+
+    *)
+        # Display directory contents.
+        if test -d "$1"; then
+            printf '=> Contents of %s:\n' "$1"
+            ls -- "$1"
+            exit 0
+        fi
+
+        # We don't handle this format.
+        exit 1
+esac
+
+# No further processing by lesspipe necessary.
+exit 0
diff --git a/shell/lesskey b/shell/lesskey
new file mode 100644 (file)
index 0000000..247679b
--- /dev/null
@@ -0,0 +1,56 @@
+# Lesskey configuration file for less.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+#command
+
+# Map "-" to go up one screen like in mutt.
+- back-screen
+# Map h and l to work like in Vim (go left/right). To display the help use H.
+h left-scroll
+l right-scroll
+
+
+#line-edit
+
+# Vim-like up/down to replace the arrow keys.
+^P up
+^N down
+
+
+#env
+
+# Set options for less.
+#
+# no-init: Disable initialization termcap as it causes the screen to get
+#          cleared on some systems.
+# quit-if-one-screen: If the output fits on the current screen quit less.
+# RAW-CONTROL-CHARS: Display ANSI "color" escape sequences to allow colored
+#                    output. Other escape sequences are drawn in caret
+#                    notation.
+# ignore-case: Ignore case if the search string doesn't contain any uppercase
+#              letters. If there are uppercase letters respect case.
+#
+# Don't use search-skip-screen as it makes it easy to miss matches on the
+# current page.
+LESS = --no-init --quit-if-one-screen --RAW-CONTROL-CHARS --ignore-case
+
+# Store less' history file in this directory. HISTORY_PATH is replaced by
+# setup.sh because lesskey doesn't expand ~/.
+LESSHISTFILE = HISTORY_PATH
+# Increase the history size, default is 100.
+LESSHISTSIZE = 1000
diff --git a/shell/reminders.in b/shell/reminders.in
new file mode 100644 (file)
index 0000000..a146029
--- /dev/null
@@ -0,0 +1,54 @@
+# remind reminder file.
+
+# Copyright (C) 2012-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# FUNCTIONS
+
+# Todo item. Prevents cluttering the calendar by displaying the entry only
+# today. Thanks to http://wiki.43folders.com/index.php/Remind_FAQ (read on
+# 2011-06-24). Additionally %"%" is used in todo items which omits them from
+# the calendar view completely. Combined this way supports `rem -c` (no todo
+# items) and `rem '*3'` (todo items only once).
+FSET todo() trigger(realtoday())
+
+
+
+# TODO LIST
+
+# Header.
+#REM [todo()] MSG %"%" TODO: %
+
+#REM [todo()] MSG %"%" - Example todo entry. %
+
+# Empty line.
+#REM [todo()] MSG %"%" %
+
+
+
+# REMINDERS
+
+#REM 04 April 2012 +10 MSG Example reminder entry. %
+
+
+
+# DAEMON REMINDERS
+
+IF $Daemon > 0
+    #REM AT 00:00 MSG Example reminder.
+ENDIF
+
+# vim: ft=remind
diff --git a/shell/screenrc.in b/shell/screenrc.in
new file mode 100644 (file)
index 0000000..a403083
--- /dev/null
@@ -0,0 +1,158 @@
+# GNU screen configuration file.
+#
+# Features which are only available in (very) recent screen releases or in
+# current Git are marked with "(GIT)" so they can be removed by the setup
+# script on machines with older versions.
+#
+# (BATTERY) is only used on laptops, (ROOT) only if running as root.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Automatically lock the screen after 10 minutes of inactivity if running as
+# root.
+#idle 600 lockscreen # handled by setup script
+
+# Don't display startup message.
+startup_message off
+
+# Use visual bell instead of audible bell.
+vbell on
+
+# Increase the scrollback buffer.
+defscrollback 50000
+
+# Ignore case when searching.
+ignorecase on
+
+# I prefer zsh as my shell. GNU screen displays a warning if the shell isn't
+# available.
+shell zsh
+
+# Don't "login" windows (= add them to the utmp database) by default. Not
+# useful for me and the "$" flag clutters the window flags (displayed with
+# %Lw).
+deflogin off
+
+
+# TERMINAL
+
+# Enable 256 color mode.
+term screen-256color
+# Allow bold colors in XTerm (not necessary for Rxvt), not sure why this is
+# necessary. Otherwise normal and bold colors are switched. Thanks to
+# http://www.frexx.de/xterm-256-notes/.
+attrcolor b ".I"
+
+
+# CAPTION AND HARDSTATUS
+
+# Use white on light blue background for highlighting and text messages (and
+# for window borders in split mode).
+sorendition = Bw
+
+# Display current battery charge if running on a laptop. Redisplay every 3
+# minutes.
+backtick 1 180 180 $HOME/.shell/bin/battery.pl -s BATTERY # (BATTERY)
+# Display current temperature if running on a laptop. Redisplay every minute.
+backtick 2 60 60 $HOME/.shell/bin/temperature.pl -s TEMPERATURE # (TEMPERATURE)
+
+# Make sure the temporary variable we use is empty. Thanks to
+# http://gist.github.com/133000 for the idea to use setenv and to TauPan in
+# #screen on Freenode (2010-03-10 16:11 CET) for reminding me of it and
+# searching it again.
+unsetenv s
+
+# Always display the caption.
+setenv s "$s%{= Bw}" # - white on light blue background, also reset all
+                     #   attributes (necessary so everything is displayed
+                     #   correctly)
+setenv s "$s%?%P"    # - is copy mode enabled? (GIT)
+setenv s "$s%{= wB}" #   - if so change colors to light blue on white (GIT)
+setenv s "$s%?"      # - end if (GIT)
+setenv s "$s%3n"     # - window number
+setenv s "$s "       # - space
+setenv s "$s%t"      # - window name
+caption always "$s"
+unsetenv s
+# Always display the status line with open windows and the hostname.
+setenv s "$s%Lw" # - number and names of windows, L displays window flags
+setenv s "$s%="  # - right align the following text
+setenv s "$s%l"  # - load average
+setenv s "$s "   # - space
+setenv s "$s%H"  # - hostname
+setenv s "$s "   # - space          (TEMPERATURE)
+setenv s "$s%2`" # - temperature    (TEMPERATURE)
+setenv s "$s "   # - space          (BATTERY)
+setenv s "$s%1`" # - battery status (BATTERY)
+hardstatus alwayslastline "$s"
+unsetenv s
+
+
+# BINDINGS
+
+# Remove some bindings I don't use to prevent using them accidentally. You
+# probably don't want to copy this.
+bind K  # kill
+bind k  # kill
+bind ^K # kill
+bind \\ # quit
+bind ^\ # quit
+bind ^Z # suspend
+bind z  # suspend
+bind ^S # xoff
+bind s  # xoff
+bind ^Q # xon
+bind q  # xon
+bind ^G # visual bell
+bind D  # power detach
+
+# Bindings for fast switching to windows 10 to 19. Thanks to skizzhg in
+# #screen on Freenode (2010-10-31 21:49 CET) for the suggestion.
+bind ; command -c window
+bind -c window 0 select 10
+bind -c window 1 select 11
+bind -c window 2 select 12
+bind -c window 3 select 13
+bind -c window 4 select 14
+bind -c window 5 select 15
+bind -c window 6 select 16
+bind -c window 7 select 17
+bind -c window 8 select 18
+bind -c window 9 select 19
+# And bindings for windows 20 to 29 with e.g. ;;1. Thanks to Kays in #irssi on
+# Freenode (2012-10-18 16:25 CEST) for the suggestion to use ;;.
+bind -c window ; command -c window2
+bind -c window2 0 select 20
+bind -c window2 1 select 21
+bind -c window2 2 select 22
+bind -c window2 3 select 23
+bind -c window2 4 select 24
+bind -c window2 5 select 25
+bind -c window2 6 select 26
+bind -c window2 7 select 27
+bind -c window2 8 select 28
+bind -c window2 9 select 29
+
+# Run urlview on current screen content. Very useful to follow links. Make
+# sure hardcopy_append is off before using this command.
+bind ^B eval "hardcopy $HOME/.tmp/screen-urlview" "screen urlview $HOME/.tmp/screen-urlview"
+
+
+# DIGRAPHS
+
+digraph (, 「
+digraph ), 」
diff --git a/shell/setup.sh b/shell/setup.sh
new file mode 100755 (executable)
index 0000000..eec1ded
--- /dev/null
@@ -0,0 +1,291 @@
+#!/bin/sh
+
+# Setup script for shell configuration files.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+. ../lib.sh
+
+
+# Helper functions.
+terminal_info() {
+    infocmp "$@" 2>&1
+}
+terminal_available() {
+    terminal_info "$@" > /dev/null
+}
+# Usage: <file> <name> <grep-string> <value>
+apply_optional_replacement() {
+    if test -n "$4"; then
+        printf '%s: using %s %s\n' "$1" "$2" "$4"
+        generate "$1" '' simple_cpp \
+            "$3" -- "$4"
+    else
+        printf '%s: removing %s display\n' "$1" "$2"
+        grep_i -v "$3" "$1"
+    fi
+}
+# Check if `infocmp` is available.
+if ! infocmp >/dev/null 2>&1; then
+    echo 'Warning: `infocmp` not available! 256color checks will fail.'
+    echo
+fi
+
+
+# DIRECTORY SETUP
+
+# Create private temporary directory used by many tools (including GNU screen
+# and tmux).
+mkdir -p ~/.tmp
+chmod 0700 ~/.tmp
+
+# Create rlwrap history directory.
+mkdir -p shell/rlwrap
+# Create zsh cache directory.
+mkdir -p zsh/cache
+
+
+# FILE SETUP
+
+# Generate ~/.less with lesskey. Prevent cluttering ~/ by storing the history
+# file in this directory; this requires replacing the constant HISTORY_PATH in
+# lesskey.
+echo 'lesskey: generating .lesskey'
+simple_cpp <lesskey \
+    HISTORY_PATH -- "`pwd`/lesshistory" \
+    | lesskey -
+chmod 0600 ~/.less
+
+# Custom colors for GNU ls.
+if installed dircolors; then
+    echo '# WARNING! DO NOT EDIT THIS FILE!' >shell/dircolors
+    dircolors -b shell/dircolors.in >>shell/dircolors
+fi
+
+# Find the required options to get colored ls output. GNU ls is preferred. See
+# shell/aliases.in for details. Doing this here instead of in shell/aliases
+# speeds up shell starts.
+#
+# GNU ls with colors available.
+if ls --color >/dev/null 2>&1; then
+    ls_args='command ls --color'
+# Normal (BSD) ls with colors available.
+elif ls -G >/dev/null 2>&1; then
+    # Don't display hidden files by default when running as root (-I), I use
+    # `la` for that.
+    ls_args='CLICOLOR_FORCE=1 command ls -G -I'
+# OpenBSD has no colored ls, use colorls instead.
+elif colorls -G >/dev/null 2>&1; then
+    ls_args='CLICOLOR_FORCE=1 colorls -G'
+# Simple ls with no colors.
+else
+    ls_args='command ls'
+fi
+
+# Also check if `column -t` is available.
+if echo test | column -t >/dev/null 2>&1; then
+    column=' | column -t'
+else
+    column=
+fi
+
+generate shell/aliases .in simple_cpp \
+    LS_ARGS COLUMN -- \
+    "$ls_args" "$column"
+
+# If `tig` is not available use my simple replacement.
+if ! installed tig; then
+    echo "alias tig='git tig'" >>shell/aliases
+fi
+
+# Check if grep supports --color=auto.
+if echo test | grep --color=auto test >/dev/null 2>&1; then
+    :
+else
+    echo 'shell/aliases: removing grep --color=auto'
+    sed_i '/^alias grep=/ s/^/#/' shell/aliases
+fi
+
+generate screenrc .in cat
+# As screen-256color is not widely supported use it only on machines where the
+# matching terminfo entry is available. This also requires a terminal emulator
+# which supports 256 colors. Also used for tmux.
+use_256colors=
+if terminal_available screen-256color; then
+    # GNU/Linux's virtual terminal doesn't support 256 colors. If setup.sh is
+    # run one one, assume this user is mostly used from the terminal.
+    if test x"$TERM" = xlinux || test x"$TERM" = xscreen.linux; then
+        echo 'screenrc: running on virtual terminal, disabling 256 colors'
+    # Called through SSH connection, assume the local system supports 256
+    # colors.
+    elif test -n "${SSH_CONNECTION:+set}"; then
+        use_256colors=1
+    # We have rxvt-unicode installed, check if it supports 256 colors.
+    elif installed urxvt; then
+        # Thanks to deryni in #rxvt-unicode on Freenode (2012-10-14 22:54
+        # CEST) for the strings/grep idea. The grep check is for "correct" 256
+        # rxvt-unicode binaries (e.g. Debian's rxvt-unicode-256color), the
+        # terminal_info check for manual installations which modify
+        # rxvt-unicode's terminfo entry.
+        urxvt_path=`installed_path urxvt`
+        urxvt_grep=`strings "$urxvt_path" | grep '^TERM=rxvt-'`
+        if test x"$urxvt_grep" = 'xTERM=rxvt-unicode-256color' \
+                || terminal_info rxvt-unicode \
+                    | grep -F 'colors#256' >/dev/null; then
+            use_256colors=1
+        fi
+    # Check if XTerm supports 256 colors (not a perfect check, but most XTerm
+    # support 256 colors).
+    elif terminal_available xterm-256color; then
+        use_256colors=1
+    fi
+fi
+if test -z "$use_256colors"; then
+    echo 'screenrc: removing 256 colors'
+    sed_i 's/Enable 256 color/Disable 256 color/;
+           s/screen-256color/screen/' screenrc
+fi
+# Some options are only necessary when running as root. They are marked as
+# "(ROOT)".
+if test "`id -u`" -ne 0; then
+    echo 'screenrc: removing root options'
+    grep_i -v '(ROOT)' screenrc
+fi
+# I use some features of GNU screen which are only in Git or very recent GNU
+# screen versions. Drop them on machines which have older versions. They are
+# marked as "(GIT)".
+if test ! -d "$HOME/development/shell/screen"; then
+    echo 'screenrc: removing Git features'
+    grep_i -v '(GIT)' screenrc
+fi
+# Rxvt doesn't need the attrcolor "fix". As I prefer rxvt assume I use it when
+# it's installed.
+if installed rxvt; then
+    echo 'screenrc: removing attrcolor "fix"'
+    sed_i 's/attrcolor b ".I"/#attrcolor b ".I"/' screenrc
+fi
+# Display current battery charge on computers with a battery. Necessary lines
+# are marked as "(BATTERY)". Also used for Tmux.
+battery=
+for x in /sys/class/power_supply/BAT*; do
+    test -d "$x" || continue
+    battery="$x"
+done
+apply_optional_replacement screenrc \
+    battery BATTERY "$battery"
+# Display current temperature. Necessary lines are marked as "(TEMPERATURE)".
+# Also used for Tmux.
+temperature=/sys/devices/platform/coretemp.0
+if ! test -d "$temperature"; then
+    temperature=
+fi
+apply_optional_replacement screenrc \
+    temperature TEMPERATURE "$temperature"
+
+
+if installed tmux; then
+    generate tmux.conf .in cat
+
+    apply_optional_replacement tmux.conf \
+        battery BATTERY "$battery"
+    apply_optional_replacement tmux.conf \
+        temperature TEMPERATURE "$temperature"
+
+    # Old Tmux versions can't handle that.
+    generate tmux.conf '' ./bin/remove-continuation.pl
+
+    # Add mappings to switch to windows 10-29 quickly. See tmux-window.pl for
+    # details.
+    perl ./tmux-window.pl 1 "`pwd`/tmux-window2.conf" >tmux-window1.conf
+    perl ./tmux-window.pl 2                           >tmux-window2.conf
+    # Set absolute path to tmux-window1.conf in tmux.conf.
+    generate tmux.conf '' simple_cpp \
+        TMUX_WINDOW_PATH -- "`pwd`/tmux-window1.conf"
+
+    # 256 colors not available.
+    if test -z "$use_256colors"; then
+        echo 'tmux.conf: removing 256 colors'
+        sed_i 's/Enable 256 color/Disable 256 color/;
+               s/screen-256color/screen/' tmux.conf
+    fi
+    # Tmux doesn't display a warning if the shell wasn't found!
+    if test ! -x '/bin/zsh'; then
+        echo 'tmux.conf: removing /bin/zsh as shell'
+        sed_i 's/zsh/sh/' tmux.conf
+    fi
+fi
+
+# Htop overwrites the comments in its configuration file.
+generate htoprc .in cat
+
+if installed dig; then
+    # dig doesn't support any comments in digrc.
+    grep -v -E '^#' digrc.in >digrc
+fi
+
+
+# LINK SETUP
+
+# Link setup for shells.
+link shell ~/.shell
+link bash ~/.bash
+link bash/rc ~/.bashrc
+link bash/profile ~/.bash_profile
+link bash/logout ~/.bash_logout
+if installed csh; then
+    link csh/rc ~/.cshrc
+fi
+link zsh ~/.zsh
+link zsh/env ~/.zshenv
+link zsh/rc ~/.zshrc
+link zsh/logout ~/.zlogout
+
+if installed tmux; then
+    link terminfo ~/.terminfo
+fi
+
+# Link setup for additional files.
+if installed crontab; then
+    link crontab.d ~/.crontab.d
+fi
+link lessfilter ~/.lessfilter
+if installed colordiff; then
+    link colordiffrc ~/.colordiffrc
+fi
+link inputrc ~/.inputrc
+if installed ghci; then
+    link haskeline ~/.haskeline
+fi
+link screenrc ~/.screenrc
+if installed tmux; then
+    link tmux.conf ~/.tmux.conf
+fi
+if installed htop; then
+    link htoprc ~/.htoprc
+    # New location for htoprc. Use both for compatibility.
+    mkdir -p ~/.config/htop
+    link htoprc ~/.config/htop/htoprc
+fi
+if test -d ~/.ssh && test -O ~/.ssh; then
+    mkdir -p ~/.ssh/master
+    link ssh_config ~/.ssh/config
+fi
+if installed dig; then
+    link digrc ~/.digrc
+fi
diff --git a/shell/shell/aliases.in b/shell/shell/aliases.in
new file mode 100644 (file)
index 0000000..69270cc
--- /dev/null
@@ -0,0 +1,134 @@
+# Aliases and similar functions which can be used by all shells (supporting
+# them).
+
+# Copyright (C) 2011-2015  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Shortcuts for often used programs.
+alias c=clear
+alias d=cd
+alias e=elinks
+alias g=git
+alias h=htop
+alias l=ls
+alias m=make
+alias p=less # p for pager
+alias s=ssh
+alias t=tig
+alias v=vim
+alias x=exit
+# Shortcuts for a little less used programs.
+alias ga='git annex'
+alias gr=grep
+alias gri='grep -i'
+alias grr='grep -r'
+alias grri='grep -ri'
+alias mc='make clean'
+alias mj='make -j$(nproc)'
+alias mu=mutt
+alias rs=reset # like git's reset alias
+alias sa='ssh-add -t 1h'
+alias te=tree
+# systemd ... (sc is provided as shell script for better completion)
+alias jc=journalctl
+alias lc=loginctl
+alias mc=machinectl
+
+
+unalias mv cp 2>/dev/null
+# Ask for confirmation before overwriting files. Especially useful when moving
+# to a different directory. No alias for `rm` because I specify the files to
+# remove directly, so I know what will happen.
+alias mv='mv -i'
+# Additionally preserve all file attributes when copying, this includes
+# copying symbolic links as is without dereferencing them.
+alias cp='cp -i -a'
+
+
+# Make sure there is no alias named ls as it causes problems with the
+# following ls function on (at least) bash 4.0.35.
+unalias ls 2>/dev/null
+# Improved ls which displays the files in columns (-C), visualizes
+# directories, links and other special files (-F) and pages everything through
+# less.
+#
+# If available use GNU ls with colorized output. If it isn't available try
+# normal ls which needs CLICOLOR_FORCE so it displays colors when used with a
+# pager. If none work no colors are used.
+#
+# See `setup.sh` for details. LS_* are replaced with the appropriate values
+# when this file is generated.
+ls() {
+    LS_ARGS -C -F "$@" 2>&1 | less
+}
+
+unalias ll lt la lal lat 2>/dev/null
+# List the files in list format with access rights, etc.
+alias ll='ls -l'
+# List the files sorted by last modification date.
+alias lt='ls -l -t'
+# List all files.
+alias la='ls -a'
+# List all files in list format with access rights, etc.
+alias lal='ls -al'
+# List all files sorted by last modification date.
+alias lat='ls -al -t'
+
+
+# Make going up directories simple.
+alias ..='cd ..'
+alias ...='cd ../..'
+alias ....='cd ../../..'
+alias .....='cd ../../../..'
+
+# Automatically use unified diffs.
+alias diff='diff -u'
+
+# COLUMN is set to `| column -t` if it's available, empty otherwise.
+
+# Display all files (-s), use human readable sizes (-h) and display the
+# complete size (-c).
+alias du='du -shc'
+# Use human readable sizes and format it nicely, thanks to climagic
+# (http://twitter.com/climagic/status/49623386762129408).
+df() {
+    command df -hP "$@" COLUMN
+}
+
+# Highlight matched strings. Doesn't work with a pager!
+alias grep='grep --color=auto'
+
+# Pipe output through less.
+tree() {
+    command tree -C "$@" | less
+}
+
+# Better viewer for info pages .. just pipe everything into less.
+info() {
+    command info "$@" 2>/dev/null | less
+}
+
+# Using su (or sudo) as root to a less privileged user might allow the other
+# user to run arbitrary commands as root. See also Debian bugs #628843 and
+# #657784.
+if test "`id -u`" -eq 0; then
+    su() {
+        echo 'never su as root' >&2
+        return 1
+    }
+fi
+
+# vim: ft=sh
diff --git a/shell/shell/bin b/shell/shell/bin
new file mode 120000 (symlink)
index 0000000..19f285a
--- /dev/null
@@ -0,0 +1 @@
+../bin
\ No newline at end of file
diff --git a/shell/shell/dircolors.in b/shell/shell/dircolors.in
new file mode 100644 (file)
index 0000000..82bafc6
--- /dev/null
@@ -0,0 +1,93 @@
+# Color settings for GNU ls. Read by `dircolors` to write the $LS_COLORS
+# environment variable.
+
+# Copyright (C) 2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# See `dircolors --print-database` for possible colors.
+
+RESET 00
+# Normal files: no color.
+NORMAL 00
+
+# Regular files: normal.
+FILE 00
+# Executable files: bold red.
+EXEC 31;01
+
+# Symbolic links: cyan (other possible value: "target", color based on target
+# type).
+LINK 36
+# Orphaned symbolic links (nonexistent or not-statable): cyan with red
+# background.
+ORPHAN 36;41
+# Regular files with multiple hard links: underlined.
+MULTIHARDLINK 04
+
+# setuid and setgid files: bold red with yellow background (red because they
+# are executables).
+SETUID 31;43;01
+SETGID 31;43;01
+
+# Directories: bold blue.
+DIR 34;01
+# Directories writable by other users and not sticky: bold blue with red
+# background.
+OTHER_WRITABLE 34;41;01
+# Directories with sticky bit and writable by others: bold blue with green
+# background.
+STICKY_OTHER_WRITABLE 34;42;01
+# Directories with sticky bit and not writable by others: bold blue with
+# yellow background.
+STICKY 34;43;01
+
+# Named pipes: green.
+FIFO 32
+# Sockets: green.
+SOCK 32
+# Block devices: normal.
+BLK 00
+# Character devices: normal.
+CHR 00
+
+
+# Color important files which might be overlooked in full directories.
+#
+# `ls` can't color matching files, only matching extensions and suffixes;
+# therefore use the suffix (which is a superset of matching extensions). As
+# most filenames have no weird suffixes like "filenameNEWS", this should work
+# fine most of the time.
+#
+# *foo matches files ending with foo, .foo only files with a foo extension
+# (e.g. example.foo).
+
+# Read-me files (e.g. README, program.readme, etc.): bold magenta.
+*README     35;01
+*README.adoc 35;01
+*README.txt 35;01
+*README.md  35;01
+*README.mkd 35;01
+*readme     35;01
+# Misc files: bold magenta.
+*NEWS 35;01
+*FAQ  35;01
+*faq  35;01
+*TODO 35;01
+*todo 35;01
+# Makefiles: bold magenta.
+*Makefile 35;01
+
+# vim: ft=dircolors
diff --git a/shell/shell/env b/shell/shell/env
new file mode 100644 (file)
index 0000000..f3e4293
--- /dev/null
@@ -0,0 +1,142 @@
+# Configuration file for environment related options for all shells.
+
+# Copyright (C) 2011-2015  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Use UTF-8 encoding in the terminal. Don't use LC_ALL as it's used for
+# debugging purposes. Thanks to twb in #screen on Freenode (2009-10-02 10:25
+# CET).
+LANG=en_US.UTF-8
+export LANG
+# Use C locale when sorting.
+LC_COLLATE=C
+export LC_COLLATE
+
+# Just in case a nice administrator tries to force LC_ALL on us ...
+unset LC_ALL
+# Also reset the rest just in case.
+unset LC_ADDRESS
+unset LC_CTYPE
+unset LC_IDENTIFICATION
+unset LC_MEASUREMENT
+unset LC_MESSAGES
+unset LC_MONETARY
+unset LC_NAME
+unset LC_NUMERIC
+unset LC_PAPER
+unset LC_TELEPHONE
+unset LC_TIME
+# Make sure $LANGUAGE is not set. It's a GNU extension which can overwrite
+# variables like $LANG or $LC_ALL.
+unset LANGUAGE
+
+# Add ~/bin, ~/.bin and ~/.shell/bin to PATH if available.
+if test -d "$HOME/.shell/bin"; then
+    PATH="$HOME/.shell/bin:$PATH"
+fi
+if test -d "$HOME/.bin"; then
+    PATH="$HOME/.bin:$PATH"
+fi
+if test -d "$HOME/bin"; then
+    PATH="$HOME/bin:$PATH"
+fi
+
+# Use Vim as editor.
+EDITOR=vim
+export EDITOR
+
+# Set less as pager, its configuration is done through the ~/.less file.
+PAGER=less
+export PAGER
+
+escape=`printf '\033'`
+# Color man pages viewed with less, thanks to [1].
+#
+# [1]: http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html
+#
+# Color bold strings in bold blue.
+LESS_TERMCAP_md="${escape}[01;34m"
+LESS_TERMCAP_me="${escape}[0m"
+export LESS_TERMCAP_md LESS_TERMCAP_me
+# Color underlined strings in bold yellow and underlined.
+LESS_TERMCAP_us="${escape}[01;4;33m"
+LESS_TERMCAP_ue="${escape}[0m"
+export LESS_TERMCAP_us LESS_TERMCAP_ue
+# Color standout mode in bold black with yellow background.
+LESS_TERMCAP_so="${escape}[01;30;43m"
+LESS_TERMCAP_se="${escape}[0m"
+export LESS_TERMCAP_so LESS_TERMCAP_se
+
+# Prefer a private and most likely fast directory (tmpfs) for temporary files
+# to reduce security problems on multi-user systems.
+if test -n "$XDG_RUNTIME_DIR" && test -d "$XDG_RUNTIME_DIR"; then
+    TMP="$XDG_RUNTIME_DIR"
+# Use ~/.tmp and ~/.tmp as fallback.
+elif test -d "$HOME/.tmp"; then
+    TMP="$HOME/.tmp"
+elif test -d "$HOME/tmp"; then
+    TMP="$HOME/tmp"
+else
+    TMP=
+fi
+if test -n "$TMP"; then
+    TEMP="$TMP"
+    TMPDIR="$TMP"
+    export TMP TEMP TMPDIR
+fi
+
+# Change rlwrap's home directory to prevent cluttering ~/.
+RLWRAP_HOME="$HOME/.shell/rlwrap"
+export RLWRAP_HOME
+
+# Set colors for GNU ls (and Zsh completions).
+if test -f "$HOME/.shell/dircolors"; then
+    . "$HOME/.shell/dircolors"
+fi
+# Set the same colors for non GNU ls, except for special cases which aren't
+# supported.
+LSCOLORS='ExgxxxxxBxxxxxBdBdExEb'
+#         ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+#         | | | | | | | | | | |
+#         | | | | | | | | | | *- directory writable to others, without sticky bit
+#         | | | | | | | | | *--- directory writable to others, with sticky bit
+#         | | | | | | | | *----- executable with setgid bit set
+#         | | | | | | | *------- executable with setuid bit set
+#         | | | | | | *--------- character special
+#         | | | | | *----------- block special
+#         | | | | *------------- executable
+#         | | | *--------------- pipe
+#         | | *----------------- socket
+#         | *------------------- symbolic link
+#         *--------------------- directory
+export LSCOLORS
+
+# Setup lesspipe to view multiple file-types (like .gz, .zip, etc.) with less.
+# Useful in combination with the "p" alias. Inspired by Debian's default bash
+# files. Thanks.
+if test -x /usr/bin/lesspipe; then
+    # Don't use eval $(lesspipe) which breaks on a few systems (e.g. Gentoo)
+    # due to a different lesspipe implementation.
+    LESSOPEN='| /usr/bin/lesspipe %s'
+    LESSCLOSE='/usr/bin/lesspipe %s %s'
+    export LESSOPEN LESSCLOSE
+fi
+
+# Additional command line options for `mtr`.
+MTR_OPTIONS='--show-ips'
+export MTR_OPTIONS
+
+# vim: ft=sh
diff --git a/shell/shell/functions b/shell/shell/functions
new file mode 100644 (file)
index 0000000..838968b
--- /dev/null
@@ -0,0 +1,30 @@
+# Shell functions useful to all shells.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Source $1 if it exists. And $1.local if it exists as well.
+source_config() {
+    if test -f "$1"; then
+        . "$1"
+    fi
+
+    if test -f "$1.local"; then
+        . "$1.local"
+    fi
+}
+
+# vim: ft=sh
diff --git a/shell/shell/logout b/shell/shell/logout
new file mode 100644 (file)
index 0000000..a5e1bbc
--- /dev/null
@@ -0,0 +1,31 @@
+# Shell logout file usable by all shells.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# When leaving the console clear the screen to increase privacy. Taken from
+# Debian default bash files and modified. Thanks.
+
+if test -x /usr/bin/clear_console; then
+    /usr/bin/clear_console -q
+else
+    clear
+fi
+
+# Make sure sudo rights are removed.
+sudo -k >/dev/null 2>&1
+
+# vim: ft=sh
diff --git a/shell/shell/rc b/shell/shell/rc
new file mode 100644 (file)
index 0000000..d0261bb
--- /dev/null
@@ -0,0 +1,117 @@
+# Shell configuration file.
+
+# Copyright (C) 2013-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Normal umask for root (readable by all users).
+if test "`id -u`" -eq 0; then
+    umask 022
+# Restricted umask for normal users (readable only by me).
+else
+    umask 077
+fi
+
+# Disable flow control (^s and ^q). I use GNU Screen/Tmux which also supports
+# this in a similar way (entering copy mode) and enabling flow control by
+# accident is annoying.
+if test -t 0; then
+    stty -ixon -ixoff
+fi
+
+# Auto-logout after timeout on TTYs. It's easy to forget to logout after
+# switching back to X11 from a TTY.
+timeout_setup_screen_lock() {
+    echo "Locking GNU screen after $timeout seconds (TTY detected)."
+    screen -X idle $timeout lockscreen
+    echo
+}
+timeout_setup_tmux_lock() {
+    if type vlock >/dev/null; then
+        echo "Locking Tmux after $timeout seconds (TTY detected)."
+        tmux set-option lock-after-time $timeout
+        echo
+
+    else
+        echo "vlock not found, locking won't work in Tmux!" >&2
+        echo "Falling back to shell timeout." >&2
+        echo
+
+        timeout_setup_shell_logout
+    fi
+}
+timeout_setup_shell_logout() {
+    echo "Auto-logout after $timeout seconds (TTY detected)."
+    TMOUT=$timeout
+    echo
+}
+# Timeout in seconds.
+local timeout >/dev/null 2>&1
+timeout=600
+case "$TERM" in
+    # `tty` doesn't work inside a pseudo-terminal as provided by GNU
+    # Screen/Tmux.
+    #
+    # The following settings for GNU Screen/Tmux will only auto-lock new
+    # sessions, not when attaching to existing sessions!
+    screen*)
+        if test -n "$STY"; then
+            case "$STY" in
+                *.tty[0-9]*.*)
+                    timeout_setup_screen_lock
+                    ;;
+            esac
+        elif test -n "$TMUX"; then
+            case "`tmux display -p '#{client_tty}'`" in
+                /dev/tty[0-9]*)
+                    timeout_setup_tmux_lock
+                    ;;
+                /dev/*)
+                    # Not on TTY, nothing to do.
+                    ;;
+                *)
+                    echo 'Tmux < 1.8 found, TTY check might be incorrect!' >&2
+
+                    local client >/dev/null 2>&1
+                    client=`printf '%s' "$TMUX" | sed 's/^.*,\([0-9]*\)$/\1/'`
+
+                    case "`tmux list-clients \
+                            | grep -E "^/dev/.*?: $client "`" in
+                        /dev/tty[0-9]*)
+                            timeout_setup_tmux_lock
+                            ;;
+                    esac
+                    ;;
+            esac
+        else
+            echo 'TERM=screen but neither $STY nor $TMUX found!' >&2
+            timeout_setup_shell_logout
+        fi
+        ;;
+
+    *)
+        case `tty` in
+            /dev/tty[0-9]*)
+                timeout_setup_shell_logout
+                ;;
+        esac
+        ;;
+esac
+unset timeout
+unset timeout_setup_screen_lock
+unset timeout_setup_tmux_lock
+unset timeout_setup_screen_lock
+
+# vim: ft=sh
diff --git a/shell/ssh_config b/shell/ssh_config
new file mode 100644 (file)
index 0000000..09995ab
--- /dev/null
@@ -0,0 +1,137 @@
+# SSH configuration file.
+#
+# Some options are set even if they are default to prevent /etc/ssh/ssh_config
+# from overwriting them.
+
+# Copyright (C) 2011-2016  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+# Undocumented (and not very well tested) feature. This drops the connection
+# after 5 seconds of inactivity. Thanks to shad0VV in #openssh on Freenode
+# (2012-11-04 18:40 CET) for telling me about this undocumented feature.
+#
+#     ServerAliveCountMax 0
+#     ServerAliveInterval 5
+
+
+# Options are parsed top-to-bottom, the first matching option is used. Later
+# assignments to the same option are ignored, thanks to anonJD in #openssh on
+# Freenode (2011-05-18 21:40 CEST) for letting me know. Therefore put all
+# affected host specific rules here, before the global rules.
+#
+# For example to change the MACs option for a specific host, use:
+#
+# Host host
+#     # Old SSH daemon which needs SHA1 (SHA-512 in case it gets updated).
+#     MACs hmac-sha2-512,hmac-sha1
+
+
+# Rules for all hosts.
+Host *
+
+# Force protocol version 2 which is more secure (default).
+    Protocol 2
+
+# Use stronger algorithms. If some hosts require weaker versions then use Host
+# groups to enable them only for those specific machines.
+
+# Don't use SHA1 and disable elliptic curves whose security regarding the
+# parameters is still in debate.
+    KexAlgorithms diffie-hellman-group-exchange-sha256
+# Use stronger cipher versions. Disable CBC ciphers to prevent (unlikely)
+# plaintext recovery attack [1], disable RC4 because it's broken [2]; this
+# leaves only AES. No GCM ciphers yet because they are still very new.
+#
+# [1]: http://www.openssh.com/txt/cbc.adv
+# [2]: http://www.schneier.com/blog/archives/2013/03/new_rc4_attack.html
+    Ciphers aes256-ctr
+# Don't use weak MACs like MD5 or SHA1. However strong MACs are not as
+# important as strong ciphers because an attacker must be able to break a MAC
+# in real time to modify the data in transmit. Prefer "-etm" algorithms which
+# use encrypt-then-mac which is more secure than the default encrypt-and-mac
+# in SSH [1] (available since 6.2).
+#
+# [1]: http://cseweb.ucsd.edu/~mihir/papers/oem.html
+    MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-512
+# Disable DSA host keys because they are weak (only 1024 bit) and elliptic
+# curves. I don't need certificates, therefore disable those algorithms as
+# well (*-cert-*).
+    HostKeyAlgorithms ssh-rsa
+
+# Disable X11 and agent forwarding for security reasons (defaults).
+    ForwardX11 no
+    ForwardAgent no
+# Don't trust remote X11 clients. If enabled allows bad admins complete access
+# to local X11!
+    ForwardX11Trusted no
+
+# Disable authentication methods I don't use.
+    ChallengeResponseAuthentication no
+    GSSAPIAuthentication no
+    HostbasedAuthentication no
+    KbdInteractiveAuthentication no
+# Only enable those I need.
+    PasswordAuthentication yes
+    PubkeyAuthentication yes
+
+# Use only authentication identity files configured in ~/.ssh/config even if
+# ssh-agent offers more identities.
+    IdentitiesOnly yes
+
+# Bind local forwardings to loopback only. This way no remote hosts can access
+# them (default).
+    GatewayPorts no
+# Abort if not all requested port forwardings can be set up.
+    ExitOnForwardFailure yes
+
+# Allow using -M (ControlMaster) to create a master SSH session which
+# "tunnels" other connections to the same host, thus reducing the number of
+# authentications (which are relatively slow) and TCP connections. The master
+# sockets are stored in ~/.ssh (by default ControlPath is not set). Using %r
+# (remote user name) might leak information to other users on the current
+# system (e.g. via netstat or lsof).
+    ControlPath ~/.ssh/master/%l-%h-%p-%r
+# Automatically create a new master session if there's none yet or use an
+# existing one. This way the user doesn't have to use -M to enable a master
+# manually. Don't set this option to "yes" or all SSH commands try to become
+# the master session which is obviously not possible.
+    ControlMaster auto
+# When the connection for a master is closed (e.g. logout of remote shell),
+# move the master connection in the background. If there's no other active
+# connection using the master, close it after x seconds. This prevents the
+# client of the master connection from blocking because it waits for all
+# connections using it to terminate which is very annoying. The timeout
+# prevents stale master connections.
+    ControlPersist 10
+
+# Don't permit running local commands (default).
+    PermitLocalCommand no
+
+# Don't send any environment variables (default).
+    SendEnv
+
+# Don't hash any hosts in ~/.ssh/known_hosts. It doesn't help if the ssh hosts
+# are stored in the shell's history file or in this file as shortcut so it's
+# rather useless (default).
+    HashKnownHosts no
+
+# Check host IP in known_hosts when connecting to detect DNS spoofing
+# (default).
+    CheckHostIP yes
+# Ask before adding any host keys to ~/.ssh/known_hosts (default).
+    StrictHostKeyChecking ask
+# Check host keys from DNS' SSHFP resource records but ask apply
+# StrictHostKeyChecking before trusting them.
+    VerifyHostKeyDNS ask
diff --git a/shell/sshd_config b/shell/sshd_config
new file mode 100644 (file)
index 0000000..0b7d95a
--- /dev/null
@@ -0,0 +1,84 @@
+# SSH daemon configuration file.
+#
+# Some options are set even if they are default to document that they are
+# important and to prevent upstream changes from affecting them.
+
+# Copyright (C) 2013-2016  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Listen on port 22 (default).
+Port 22
+
+# Only use protocol 2. Protocol 1 is insecure. (default)
+Protocol 2
+
+# Stronger algorithms. See ssh_config for details.
+KexAlgorithms diffie-hellman-group-exchange-sha256
+Ciphers aes256-ctr
+MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-512
+
+# Use privilege separation for increased security. "sandbox" applies
+# additional restrictions on the unprivileged process.
+UsePrivilegeSeparation sandbox
+
+# Don't use PAM because it may circumvent other authentication methods used
+# below (default).
+UsePAM no
+# Disable authentication methods I don't use.
+ChallengeResponseAuthentication no
+GSSAPIAuthentication no
+HostbasedAuthentication no
+KbdInteractiveAuthentication no
+KerberosAuthentication no
+PasswordAuthentication no
+# Only enable those I need.
+PubkeyAuthentication yes
+
+# Don't allow empty passwords (default).
+PermitEmptyPasswords no
+# Allow root-login only with public keys.
+PermitRootLogin without-password
+
+# Be strict when checking user file permissions (default).
+StrictModes yes
+
+# Allow more sessions per network connection (e.g. from ControlMaster/-M).
+# When not enough sessions are available this message is sent by ssh:
+# "mux_client_request_session: session request failed: Session open refused by
+# peer".
+MaxSessions 30
+
+# Don't accept any environment variables from the client (default).
+AcceptEnv
+# Don't use ~/.ssh/environment and environment= options in
+# ~/.ssh/authorized_keys because LD_PRELOAD could be used to circumvent
+# authentications (default).
+PermitUserEnvironment no
+
+# Send a message after the given seconds of inactivity through the encrypted
+# channel. Used to detect stale connections more quickly. Not necessary on all
+# servers.
+#ClientAliveInterval 60
+# Disconnect the client if more than max count alive messages were lost
+# (default). With the setting above this detects a broken connection after 3
+# minutes.
+ClientAliveCountMax 3
+
+# Enable sftp (and sshfs) usage. internal-sftp also works in chroots.
+Subsystem sftp internal-sftp
+
+# Only allow logins for certain users.
+AllowUsers root
diff --git a/shell/terminfo/README b/shell/terminfo/README
new file mode 100644 (file)
index 0000000..3c91b00
--- /dev/null
@@ -0,0 +1,5 @@
+README
+======
+
+screen-it-256color is a modified screen-256color terminfo which handles italic
+text for Tmux correctly.
diff --git a/shell/terminfo/s/screen-it-256color b/shell/terminfo/s/screen-it-256color
new file mode 100644 (file)
index 0000000..8651f3c
Binary files /dev/null and b/shell/terminfo/s/screen-it-256color differ
diff --git a/shell/tmux-window.pl b/shell/tmux-window.pl
new file mode 100644 (file)
index 0000000..5e2601c
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+
+# Helper script to support quick window jumping with a prefix key for 0-9 in
+# Tmux.
+
+# At the moment Tmux doesn't support mappings with multiple keys, e.g. prefix
+# ;0, prefix ;1 etc. (where ; is the common secondary prefix key). But this
+# works in GNU screen and is very useful to switch to windows quickly, e.g.
+# prefix ;3 to switch to window 13 or prefix ;;5 to switch to window 25.
+#
+# To simulate this missing feature ; and 0-9 must be rebound when prefix ; is
+# used, and unbound when ; or 0-9 was pressed and the window selected. This
+# script generates these tedious mappings.
+#
+# For each number (0-9) the following mapping is generated (example with 0):
+#
+#     bind-key -n 0 unbind-key -n 0 \; \
+#                   ...
+#                   unbind-key -n 9 \; \
+#                   unbind-key -n \\; \         # this unmaps ;
+#                   select-window -t :10 \;
+#
+# Due to Tmux's handling of errors, they abort the rest of the mapping, the
+# select-window command is executed as last part of the mapping.
+#
+# If a secondary chaining (e.g. prefix ;;3) is requested, a second file like
+# the generated one must be loaded with ; to jump to windows 20-29. Therefore
+# the following line is added in this case.
+#
+#     bind-key -n \; source-file "/path/to/second/file"
+#
+# To use these mappings first create the files using this script. To switch to
+# windows 10-19 with ;0-;9 and to 20-29 with ;;0-;;9 run these commands (can
+# be chained indefinitely):
+#
+#     $ perl ./tmux-window.pl 1 "`pwd`/tmux-window2.conf" > tmux-window1.conf
+#     $ perl ./tmux-window.pl 2                           > tmux-window2.conf
+#
+# Then add the following to your tmux.conf:
+#
+#     bind-key \; source-file "/path/to/tmux-window1.conf"
+#
+# tmux-window1.conf automatically contains the path to tmux-window2.conf,
+# therefore chaining for ;;3 will work to jump to window 23.
+
+# Copyright (C) 2012-2013  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+if (scalar @ARGV != 1 && scalar @ARGV != 2) {
+    print STDERR "Usage: $0 <level> [</path/to/tmux-window.conf>]\n";
+    exit 1;
+}
+
+my $level = $ARGV[0];
+my $path  = $ARGV[1];
+
+if (defined $path and $path !~ m{^/}) {
+    print STDERR "<path> must be an absolute path!\n";
+    exit 2;
+}
+
+
+for (my $i = 0; $i < 10; $i++) {
+    print "bind-key -n $i ";
+    for (my $j = 0; $j < 10; $j++) {
+        print "unbind-key -n $j \\; ";
+    }
+    print "unbind-key -n \\\\; \\; ";
+    # Do the select-window last. If the window doesn't exist the failing
+    # select-window command prevents unbinding the other keys.
+    print "select-window -t :$level$i\n";
+}
+
+if (defined $path) {
+    print "bind-key -n \\; source-file \"$path\"\n";
+}
diff --git a/shell/tmux.conf.in b/shell/tmux.conf.in
new file mode 100644 (file)
index 0000000..6d582d9
--- /dev/null
@@ -0,0 +1,133 @@
+# Tmux configuration file.
+#
+# Notes:
+#
+# - To swap/renumber windows (like GNU screen's :number command) use
+#   :swap-window -t <number>.
+# - GNU screen's screen -x can be replicated with tmux new-session -t.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# GENERAL
+
+# Use vlock to lock the screen. Tmux doesn't have an internal lock program
+# like GNU screen!
+set-option -g lock-command "vlock"
+# Lock sessions individually. Otherwise lock-after-time will wait on all other
+# sessions to idle before it locks this session.
+set-option -g lock-server off
+
+# Use Zsh as shell. Tmux does not display a warning if the shell isn't
+# available!
+set-option -g default-shell "/bin/zsh"
+
+# Use a larger window history, in lines.
+set-option -g history-limit 50000
+
+# Display Tmux messages for a longer time, in milliseconds.
+set-option -g display-time 3000
+
+# Open new windows with the current working directory used when Tmux was
+# started, and not the working directory of the current pane.
+set-option -g default-path "."
+
+
+# TERMINAL
+
+# Enable 256 color mode.
+set-option -g default-terminal "screen-256color"
+
+# Disable alternative screen feature. This way e.g. Vim's window content stays
+# visible after quitting Vim. This is quite useful to copy data (needs tmux
+# 1.5 to work (almost) completely).
+set-window-option -g alternate-screen off
+
+# Set title for outer terminal.
+set-option -g set-titles on
+
+# Don't rename windows to the currently running program, my zshrc does this
+# for me (with some additional features).
+set-window-option -g automatic-rename off
+
+
+# STATUS LINE
+
+# White text.
+set-option -g status-fg white
+# Bright blue background color (colour12).
+set-option -g status-bg colour12
+
+# Nothing left of window list.
+set-option -g status-left ""
+# Current load average and hostname (#H) on the right.
+set-option -g status-right "#(uptime | sed 's/^.*load averages*: //; s/,//g') \
+                            #H \
+                            #(~/.shell/bin/temperature.pl -t TEMPERATURE)\
+                            #[] #(~/.shell/bin/battery.pl -t BATTERY)\
+                            "
+
+# Format for windows in the window list in the status line. #I window index,
+# #W window number, #F window flags.
+set-window-option -g window-status-format         "#I #W#F"
+set-window-option -g window-status-current-format "#I #W#F"
+
+# Update status line commands (#(..)) only every minute.
+set-option -g status-interval 60
+
+
+# BINDINGS
+
+# Use Vi(m) key bindings.
+set-option        -g status-keys vi
+set-window-option -g mode-keys vi
+
+# Use Ctrl-A as escape binding, like in GNU screen.
+set-option -g prefix C-a
+# Ctrl-A a sends Ctrl-A to the process, like in GNU screen.
+bind-key a send-prefix
+unbind-key C-b
+
+# GNU screen like bindings (with C-x).
+bind-key C-c new-window
+bind-key C-a last-window
+bind-key C-n next-window
+bind-key C-p previous-window
+bind-key C-[ copy-mode
+bind-key C-] paste-buffer
+
+# Arrow-key replacements for tmux's prompt.
+bind-key -t vi-edit C-n history-down
+bind-key -t vi-edit C-p history-up
+
+# Display date/time, similar to GNU screen's ^a ^t. Tmux's default ^a t just
+# displays the current time, but I often want to know the current date.
+bind-key C-t display-message
+
+# Run urlview on the current screen content. Very useful to follow links.
+# Thanks to Arch wiki (https://wiki.archlinux.org/index.php/Tmux) for the
+# basic idea how to enable this in tmux.
+bind-key C-b capture-pane \; \
+             save-buffer ~/.tmp/tmux-urlview \; \
+             delete-buffer \; \
+             new-window "urlview <~/.tmp/tmux-urlview"
+
+# Binding for fast switching to windows 10 to 29 (and more if necessary).
+# Thanks to Kays in #irssi on Freenode (2012-10-18 16:25 CEST) for reminding
+# me of this issue in Tmux. See tmux-windows.pl for details how it works.
+bind-key \; source-file "TMUX_WINDOW_PATH"
+
+# vim: ft=tmux
diff --git a/shell/zsh/env b/shell/zsh/env
new file mode 100644 (file)
index 0000000..30483a0
--- /dev/null
@@ -0,0 +1,35 @@
+# Zsh configuration file for environment related options.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+. ~/.shell/functions
+
+source_config ~/.shell/env
+
+
+# Make sure elements in PATH are unique.
+typeset -U path PATH
+
+# Use $TMPDIR/zsh as directory for temporary Zsh files to prevent symlink
+# attacks - only helps if $TMPDIR points to a safe directory (which should be
+# true with the settings in shell/env).
+TMPPREFIX="$TMPDIR/zsh"
+
+
+source_config ~/.zsh/env.local
+
+# vim: ft=zsh
diff --git a/shell/zsh/functions/_systemctl b/shell/zsh/functions/_systemctl
new file mode 100644 (file)
index 0000000..c440dd7
--- /dev/null
@@ -0,0 +1,418 @@
+#compdef systemctl
+
+(( $+functions[_systemctl_command] )) || _systemctl_command()
+{
+  local -a _systemctl_cmds
+  _systemctl_cmds=(
+    "list-sockets:List sockets"
+    "list-timers:List timers"
+    "list-units:List units"
+    "start:Start (activate) one or more units"
+    "stop:Stop (deactivate) one or more units"
+    "reload:Reload one or more units"
+    "restart:Start or restart one or more units"
+    "condrestart:Restart one or more units if active"
+    "try-restart:Restart one or more units if active"
+    "reload-or-restart:Reload one or more units if possible, otherwise start or restart"
+    "force-reload:Reload one or more units if possible, otherwise restart if active"
+    "hibernate:Hibernate the system"
+    "hybrid-sleep:Hibernate and suspend the system"
+    "reload-or-try-restart:Reload one or more units if possible, otherwise restart if active"
+    "isolate:Start one unit and stop all others"
+    "kill:Send signal to processes of a unit"
+    "is-active:Check whether units are active"
+    "is-failed:Check whether units are failed"
+    "status:Show runtime status of one or more units"
+    "show:Show properties of one or more units/jobs or the manager"
+    "cat:Show the source unit files and drop-ins"
+    "reset-failed:Reset failed state for all, one, or more units"
+    "list-unit-files:List installed unit files"
+    "enable:Enable one or more unit files"
+    "disable:Disable one or more unit files"
+    "reenable:Reenable one or more unit files"
+    "preset:Enable/disable one or more unit files based on preset configuration"
+    "set-default:Set the default target"
+    "get-default:Query the default target"
+    "edit:Edit one or more unit files"
+    "is-system-running:Query overall status of the system"
+    "help:Show documentation for specified units"
+    "list-dependencies:Show unit dependency tree"
+    "mask:Mask one or more units"
+    "unmask:Unmask one or more units"
+    "link:Link one or more units files into the search path"
+    "is-enabled:Check whether unit files are enabled"
+    "list-jobs:List jobs"
+    "cancel:Cancel all, one, or more jobs"
+    "snapshot:Create a snapshot"
+    "delete:Remove one or more snapshots"
+    "show-environment:Dump environment"
+    "set-environment:Set one or more environment variables"
+    "unset-environment:Unset one or more environment variables"
+    "daemon-reload:Reload systemd manager configuration"
+    "daemon-reexec:Reexecute systemd manager"
+    "default:Enter system default mode"
+    "rescue:Enter system rescue mode"
+    "emergency:Enter system emergency mode"
+    "halt:Shut down and halt the system"
+    "suspend:Suspend the system"
+    "poweroff:Shut down and power-off the system"
+    "reboot:Shut down and reboot the system"
+    "kexec:Shut down and reboot the system with kexec"
+    "exit:Ask for user instance termination"
+    "switch-root:Change root directory"
+  )
+
+  if (( CURRENT == 1 )); then
+    _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@"
+  else
+    local curcontext="$curcontext" expl
+
+    cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}"
+    # Deal with any aliases
+    case $cmd in
+      condrestart) cmd="try-restart";;
+      force-reload) cmd="reload-or-try-restart";;
+    esac
+
+    # CHANGED: my aliases
+    case $words[1] in
+      c)  cmd=cat     ;;
+      d)  cmd=disable ;;
+      e)  cmd=enable  ;;
+      k)  cmd=kill    ;;
+      m)  cmd=mask    ;;
+      r)  cmd=restart ;;
+      rl) cmd=reload  ;;
+      s)  cmd=status  ;;
+      sa) cmd=start   ;;
+      so) cmd=stop    ;;
+      u)  cmd=unmask  ;;
+    esac
+
+    if (( $#cmd )); then
+      curcontext="${curcontext%:*:*}:systemctl-${cmd}:"
+
+      local update_policy
+      zstyle -s ":completion:${curcontext}:" cache-policy update_policy
+      if [[ -z "$update_policy" ]]; then
+        zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy
+      fi
+
+      _call_function ret _systemctl_$cmd || _message 'no more arguments'
+    else
+      _message "unknown systemctl command: $words[1]"
+    fi
+    return ret
+  fi
+}
+
+__systemctl()
+{
+  systemctl $_sys_service_mgr --full --no-legend --no-pager "$@"
+}
+
+
+# Fills the unit list
+_systemctl_all_units()
+{
+  if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
+    ! _retrieve_cache SYS_ALL_UNITS;
+  then
+    _sys_all_units=( ${${(f)"$(__systemctl list-units --all)"}%% *} )
+    _store_cache SYS_ALL_UNITS _sys_all_units
+  fi
+}
+
+# Fills the unit list including all file units
+_systemctl_really_all_units()
+{
+  local -a all_unit_files;
+  local -a really_all_units;
+  if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
+    ! _retrieve_cache SYS_REALLY_ALL_UNITS;
+  then
+    all_unit_files=( ${${(f)"$(__systemctl list-unit-files)"}%% *} )
+    _systemctl_all_units
+    really_all_units=($_sys_all_units $all_unit_files)
+    _sys_really_all_units=(${(u)really_all_units})
+    _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units
+  fi
+}
+
+_filter_units_by_property() {
+  local property=$1 value=$2 ; shift ; shift
+  local -a units ; units=($*)
+  local props
+  for props in ${(ps:\n\n:)"$(_call_program units "$service show --no-pager --property="Id,$property" -- ${units} 2>/dev/null")"}; do
+    props=(${(f)props})
+    if [[ "${props[2]}" = "$property=$value" ]]; then
+      echo -E - " ${props[1]#Id=}"
+    fi
+  done
+}
+
+_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files)"}##*@.[^[:space:]]##}%%@.*}\@ }
+
+
+_systemctl_active_units()  {_sys_active_units=(  ${${(f)"$(__systemctl list-units)"}%% *} )}
+
+_systemctl_startable_units(){
+    _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
+                          _filter_units_by_property CanStart yes $(
+                          __systemctl $mode list-unit-files --state enabled,disabled,static | \
+                               { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
+                          __systemctl $mode list-units --state inactive,failed | \
+                               { while read -r a b; do echo -E - " $a"; done; } )) ) )
+}
+
+_systemctl_restartable_units(){
+    _sys_restartable_units=( $(_filter_units_by_property CanStart yes $(
+                          __systemctl $mode list-unit-files --state enabled,disabled,static | \
+                               { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
+                          __systemctl $mode list-units | \
+                               { while read -r a b; do echo -E - " $a"; done; } )) )
+}
+
+_systemctl_failed_units()  {_sys_failed_units=( ${${(f)"$(__systemctl list-units --failed)"}%% *} ) }
+_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files) ) }
+
+local fun
+# Completion functions for ALL_UNITS
+for fun in is-active is-failed is-enabled status show cat mask preset help list-dependencies edit ; do
+  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
+  {
+    _systemctl_really_all_units
+    _wanted systemd-units expl unit \
+      compadd "$@" -a - _sys_really_all_units
+  }
+done
+
+# Completion functions for ENABLED_UNITS
+(( $+functions[_systemctl_disable] )) || _systemctl_disable()
+{
+    local _sys_unit_state; _systemctl_unit_state
+    _wanted systemd-units expl 'enabled unit' \
+      compadd "$@" - ${(k)_sys_unit_state[(R)enabled]}
+}
+
+(( $+functions[_systemctl_reenable] )) || _systemctl_reenable()
+{
+    local _sys_unit_state; _systemctl_unit_state
+    _wanted systemd-units expl 'enabled/disabled unit' \
+      compadd "$@" - ${(k)_sys_unit_state[(R)(enabled|disabled)]} $(_systemctl_get_template_names)
+}
+
+# Completion functions for DISABLED_UNITS
+(( $+functions[_systemctl_enable] )) || _systemctl_enable()
+{
+  local _sys_unit_state; _systemctl_unit_state
+  _wanted systemd-units expl 'disabled unit' \
+    compadd "$@" - ${(k)_sys_unit_state[(R)disabled]} $(_systemctl_get_template_names)
+}
+
+# Completion functions for FAILED_UNITS
+(( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed()
+{
+  local _sys_failed_units; _systemctl_failed_units
+  _wanted systemd-units expl 'failed unit' \
+    compadd "$@" -a - _sys_failed_units || _message "no failed unit found"
+}
+
+# Completion functions for STARTABLE_UNITS
+(( $+functions[_systemctl_start] )) || _systemctl_start()
+{
+   local _sys_startable_units; _systemctl_startable_units
+   _wanted systemd-units expl 'startable unit' \
+     compadd "$@" - ${_sys_startable_units[*]} $(_systemctl_get_template_names)
+}
+
+# Completion functions for STOPPABLE_UNITS
+for fun in stop kill try-restart condrestart ; do
+  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
+  {
+    local _sys_active_units; _systemctl_active_units
+    _wanted systemd-units expl 'stoppable unit' \
+      compadd "$@" - $( _filter_units_by_property CanStop yes \
+        ${_sys_active_units[*]} )
+  }
+done
+
+# Completion functions for ISOLATABLE_UNITS
+(( $+functions[_systemctl_isolate] )) || _systemctl_isolate()
+{
+  _systemctl_all_units
+  _wanted systemd-units expl 'isolatable unit' \
+    compadd "$@" - $( _filter_units_by_property AllowIsolate yes \
+      ${_sys_all_units[*]} )
+}
+
+# Completion functions for RELOADABLE_UNITS
+for fun in reload reload-or-try-restart force-reload ; do
+  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
+  {
+    local _sys_active_units; _systemctl_active_units
+    _wanted systemd-units expl 'reloadable unit' \
+      compadd "$@" - $( _filter_units_by_property CanReload yes \
+        ${_sys_active_units[*]} )
+  }
+done
+
+# Completion functions for RESTARTABLE_UNITS
+for fun in restart reload-or-restart ; do
+  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
+  {
+    local _sys_restartable_units; _systemctl_restartable_units
+    _wanted systemd-units expl 'restartable unit' \
+      compadd "$@" - ${_sys_restartable_units[*]} $(_systemctl_get_template_names)
+  }
+done
+
+# Completion functions for MASKED_UNITS
+(( $+functions[_systemctl_unmask] )) || _systemctl_unmask()
+{
+  local _sys_unit_state; _systemctl_unit_state
+  _wanted systemd-units expl 'masked unit' \
+    compadd "$@" - ${(k)_sys_unit_state[(R)masked]} || _message "no masked units found"
+}
+
+# Completion functions for JOBS
+(( $+functions[_systemctl_cancel] )) || _systemctl_cancel()
+{
+  _wanted systemd-jobs expl job \
+    compadd "$@" - ${${(f)"$(__systemctl list-jobs)"}%% *} ||
+      _message "no jobs found"
+}
+
+# Completion functions for SNAPSHOTS
+(( $+functions[_systemctl_delete] )) || _systemctl_delete()
+{
+  _wanted systemd-snapshots expl snapshot \
+    compadd "$@" - ${${(f)"$(__systemctl list-units --type snapshot --all)"}%% *} ||
+      _message "no snapshots found"
+}
+
+# Completion functions for TARGETS
+(( $+functions[_systemctl_set-default] )) || _systemctl_set-default()
+{
+  _wanted systemd-targets expl target \
+    compadd "$@" - ${${(f)"$(__systemctl list-unit-files --type target --all)"}%% *} ||
+      _message "no targets found"
+}
+
+# Completion functions for ENVS
+for fun in set-environment unset-environment ; do
+  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
+  {
+    local fun=$0 ; fun=${fun##_systemctl_}
+    local suf
+    if [[ "${fun}" = "set-environment" ]]; then
+      suf='-S='
+    fi
+    _wanted systemd-environment expl 'environment variable' \
+      compadd "$@" ${suf} - ${${(f)"$(systemctl show-environment)"}%%=*}
+  }
+done
+
+(( $+functions[_systemctl_link] )) || _systemctl_link() {
+   _sd_unit_files
+}
+
+(( $+functions[_systemctl_switch-root] )) || _systemctl_switch-root() {
+   _files
+}
+
+# no systemctl completion for:
+#    [STANDALONE]='daemon-reexec daemon-reload default
+#                  emergency exit halt kexec list-jobs list-units
+#                  list-unit-files poweroff reboot rescue show-environment'
+#         [NAME]='snapshot'
+
+_systemctl_caching_policy()
+{
+  local _sysunits
+  local -a oldcache
+
+  # rebuild if cache is more than a day old
+  oldcache=( "$1"(mh+1) )
+  (( $#oldcache )) && return 0
+
+  _sysunits=(${${(f)"$(__systemctl --all)"}%% *})
+
+  if (( $#_sysunits )); then
+    for unit in $_sysunits; do
+      [[ "$unit" -nt "$1" ]] && return 0
+    done
+  fi
+
+  return 1
+}
+
+_unit_states() {
+    local -a _states
+    _states=(loaded failed active inactive not-found listening running waiting plugged mounted exited dead masked)
+    _values -s , "${_states[@]}"
+}
+
+_unit_types() {
+    local -a _types
+    _types=(automount busname device mount path service snapshot socket swap target timer)
+    _values -s , "${_types[@]}"
+}
+
+_unit_properties() {
+  if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES ) &&
+    ! _retrieve_cache SYS_ALL_PROPERTIES;
+  then
+    _sys_all_properties=( ${${(M)${(f)"$(__systemctl show --all;
+    /lib/systemd/systemd --dump-configuration-items)"}##[[:alnum:]]##=*}%%=*}
+    )
+    _store_cache SYS_ALL_PROPRTIES _sys_all_properties
+  fi
+  _values -s , "${_sys_all_properties[@]}"
+}
+
+_job_modes() {
+    local -a _modes
+    _modes=(fail replace replace-irreversibly isolate ignore-dependencies ignore-requirements flush)
+    _values -s , "${_modes[@]}"
+}
+
+local -a _modes; _modes=("--user" "--system")
+local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}
+_arguments -s \
+    {-h,--help}'[Show help]' \
+    '--version[Show package version]' \
+    {-t+,--type=}'[List only units of a particular type]:unit type:_unit_types' \
+    '--state=[Display units in the specified state]:unit state:_unit_states' \
+    '--job-mode=[Specify how to deal with other jobs]:mode:_job_modes' \
+    {-p+,--property=}'[Show only properties by specific name]:unit property:_unit_properties' \
+    {-a,--all}'[Show all units/properties, including dead/empty ones]' \
+    '--reverse[Show reverse dependencies]' \
+    '--after[Show units ordered after]' \
+    '--before[Show units ordered before]' \
+    '--failed[Show only failed units]' \
+    {-l,--full}"[Don't ellipsize unit names on output]" \
+    '--show-types[When showing sockets, show socket type]' \
+    {-i,--ignore-inhibitors}'[When executing a job, ignore jobs dependencies]' \
+    {-q,--quiet}'[Suppress output]' \
+    '--no-block[Do not wait until operation finished]' \
+    '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
+    '--no-pager[Do not pipe output into a pager]' \
+    '--system[Connect to system manager]' \
+    '--user[Connect to user service manager]' \
+    "--no-wall[Don't send wall message before halt/power-off/reboot]" \
+    '--global[Enable/disable unit files globally]' \
+    "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \
+    '--no-ask-password[Do not ask for system passwords]' \
+    '--kill-who=[Who to send signal to]:killwho:(main control all)' \
+    {-s+,--signal=}'[Which signal to send]:signal:_signals' \
+    {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \
+    '--root=[Enable unit files in the specified root directory]:directory:_directories' \
+    '--runtime[Enable unit files only temporarily until next reboot]' \
+    {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
+    {-P,--privileged}'[Acquire privileges before execution]' \
+    {-n+,--lines=}'[Journal entries to show]:number of entries' \
+    {-o+,--output=}'[Change journal output mode]:modes:_sd_outputmodes' \
+    '--firmware-setup[Tell the firmware to show the setup menu on next boot]' \
+    '--plain[When used with list-dependencies, print output as a list]' \
+    '*::systemctl command:_systemctl_command'
diff --git a/shell/zsh/functions/extract b/shell/zsh/functions/extract
new file mode 100644 (file)
index 0000000..5a73454
--- /dev/null
@@ -0,0 +1,41 @@
+# Author: Copyright © 2005 Eric P. Mangold - teratorn (-at-) gmail (-dot) com
+# License: MIT. http://www.opensource.org/licenses/mit-license.html
+# http://zshwiki.org/home/examples/functions
+
+local old_dirs current_dirs lower
+lower=${(L)1}
+old_dirs=( *(N/) )
+if [[ $lower == *.tar.gz || $lower == *.tgz ]]; then
+    tar zxfv $1
+elif [[ $lower == *.gz ]]; then
+    gunzip $1
+elif [[ $lower == *.tar.bz2 || $lower == *.tbz ]]; then
+    bunzip2 -c $1 | tar xfv -
+elif [[ $lower == *.bz2 ]]; then
+    bunzip2 $1
+elif [[ $lower == *.zip ]]; then
+    unzip $1
+elif [[ $lower == *.rar ]]; then
+    unrar e $1
+elif [[ $lower == *.tar ]]; then
+    tar xfv $1
+elif [[ $lower == *.lha ]]; then
+    lha e $1
+else
+    print "Unknown archive type: $1"
+    return 1
+fi
+# Change in to the newly created directory, and
+# list the directory contents, if there is one.
+current_dirs=( *(N/) )
+for i in {1..${#current_dirs}}; do
+    if [[ $current_dirs[$i] != $old_dirs[$i] ]]; then
+        cd $current_dirs[$i]
+        ls
+        break
+    fi
+done
+
+#compdef '_files -g "*.gz *.tgz *.bz2 *.tbz *.zip *.rar *.tar *.lha"' extract_archive
+
+# vim: ft=zsh
diff --git a/shell/zsh/logout b/shell/zsh/logout
new file mode 100644 (file)
index 0000000..a540ec8
--- /dev/null
@@ -0,0 +1,21 @@
+# Zsh logout file.
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+source_config ~/.shell/logout
+
+# vim: ft=zsh
diff --git a/shell/zsh/rc b/shell/zsh/rc
new file mode 100644 (file)
index 0000000..7222619
--- /dev/null
@@ -0,0 +1,1119 @@
+# Zsh configuration file.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Warn when creating global variables from inside a function. Needs to be set
+# before declaring a function.
+setopt warn_create_global
+
+
+# HELPER FUNCTIONS
+
+# Return the name of the program which is called in the foreground with `fg`.
+# $1 is the name of the program (optional). If it's not 'fg' or 'fg *' it's
+# returned unchanged.
+zshrc_resolve_fg_to_resumed_job_name() {
+    # $REPLY is used by convention for scalars ($reply for arrays) to return
+    # values from functions. unset it here to prevent problems when REPLY is
+    # bound to an integer or similar. Thanks to Mikachu in #zsh on Freenode
+    # (2012-09-27 17:14 CEST) for this hint.
+    unset REPLY
+
+    # Replace fg with the resumed job name.
+    if [[ $1 == fg ]]; then
+        REPLY=${jobtexts[%+]}
+    elif [[ $1 == fg\ * ]]; then
+        REPLY=${jobtexts[${1#fg }]}
+    # Normal program, return as is.
+    else
+        REPLY=$1
+    fi
+}
+
+
+# MISCELLANEOUS SETTINGS
+
+# Prevent warnings.
+typeset -g TMOUT
+# Load general shell setup commands. NOTE: Expand this when publishing the
+# config.
+source_config ~/.shell/rc
+
+# Disable beeps.
+setopt nobeep
+
+# Prevent overwriting existing files with '> filename', use '>| filename'
+# (or >!) instead.
+setopt noclobber
+
+# Entering the name of a directory (if it's not a command) will automatically
+# cd to that directory.
+setopt autocd
+
+# When entering a nonexistent command name automatically try to find a similar
+# one.
+setopt correct
+
+# Enable zsh's extended glob abilities.
+setopt extendedglob
+
+# Don't exit if <C-D> is pressed. Prevents exiting the shell by accident (e.g.
+# pressing <C-D> twice).
+setopt ignoreeof
+
+# Also display PID when suspending a process.
+setopt longlistjobs
+
+
+# KEY BINDINGS
+
+# Not all bindings are done here, only those not specific to a given section.
+
+# Use Vi(m) style key bindings.
+bindkey -v
+
+# Use jk to exit insert mode (jj is too slow to type).
+bindkey 'jk' vi-cmd-mode
+
+# I don't need the arrow keys, I use ^N and ^P for this (see below).
+bindkey -r '^[OA' '^[OB' '^[OC' '^[OD' '^[[A' '^[[B' '^[[C' '^[[D'
+# Also not in Vi mode.
+bindkey -a -r '^[OA' '^[OB' '^[OC' '^[OD' '^[[A' '^[[B' '^[[C' '^[[D'
+
+
+# FUNCTION SETTINGS
+
+# Make sure every entry in $fpath is unique.
+typeset -U fpath
+# ~/.zsh/functions/completion is a symbolic link to the Completion directory
+# of a Zsh Git checkout. Use it to get the newest completions if available.
+if [[ -d ~/.zsh/functions/completion ]]; then
+    fpath=(~/.zsh/functions/completion/*/*(/) $fpath)
+fi
+# Set correct fpath to allow loading my functions (including completion
+# functions).
+fpath=(~/.zsh/functions $fpath)
+# Autoload my functions (except completion functions and hidden files). Thanks
+# to caphuso from the Zsh example files for this idea.
+if [[ -d ~/.zsh/functions ]]; then
+    autoload -Uz ${fpath[1]}/^_*(^/:t)
+fi
+
+# Simulate hooks using _functions arrays for Zsh versions older than 4.3.4. At
+# the moment only precmd(), preexec() and chpwd() are simulated.
+if [[ $ZSH_VERSION != (4.3.<4->*|4.<4->*|<5->*) ]]; then
+    # Run all functions defined in the ${precmd,preexec,chpwd}_functions
+    # arrays.
+    function precmd() {
+        for function in $precmd_functions; do
+            $function "$@"
+        done
+    }
+    function preexec() {
+        for function in $preexec_functions; do
+            $function "$@"
+        done
+    }
+    function chpwd() {
+        for function in $chpwd_functions; do
+            $function "$@"
+        done
+    }
+fi
+
+# Load zmv (zsh move) which is a powerful file renamer.
+autoload -Uz zmv
+
+
+# HISTORY SETTINGS
+
+# Use history and store it in ~/.zsh/history.
+HISTSIZE=1000000
+SAVEHIST=1000000
+HISTFILE=~/.zsh/history
+# Append to the history file instead of overwriting it and do it immediately
+# when a command is executed.
+setopt appendhistory
+setopt incappendhistory
+# If the same command is run multiple times store it only once in the history.
+setopt histignoredups
+# Don't add lines starting with a space to the history.
+setopt histignorespace
+
+# Vim like completions of previous executed commands (also enter Vi-mode). If
+# called at the beginning it just recalls old commands (like cursor up), if
+# called after typing something, only lines starting with the typed text are
+# returned. Very useful to get old commands quickly - in addition to the
+# history commands (!..). Thanks to Mikachu in #zsh on Freenode (2010-01-17
+# 12:47 CET) for the information how to a use function with bindkey.
+zle -N zshrc-vi-history-beginning-search-backward
+zshrc-vi-history-beginning-search-backward() {
+    local not_at_beginning_of_line
+    if [[ $CURSOR -ne 0 ]]; then
+        not_at_beginning_of_line=yes
+    fi
+
+    zle history-beginning-search-backward
+
+    # Start Vi-mode and stay at the same position (Vi-mode moves one left,
+    # this counters it).
+    zle vi-cmd-mode
+    if [[ -n $not_at_beginning_of_line ]]; then
+        zle vi-forward-char
+    fi
+}
+bindkey '^P' zshrc-vi-history-beginning-search-backward
+bindkey -a '^P' history-beginning-search-backward # binding for Vi-mode
+# Here only Vi-mode is necessary as ^P enters Vi-mode and ^N only makes sense
+# after calling ^P.
+bindkey -a '^N' history-beginning-search-forward
+
+# Enable incremental search which is especially useful when the string is an
+# argument and not the command.
+bindkey '^R' history-incremental-pattern-search-backward
+# Also enable my usual use of Ctrl-P/Ctrl-N to get the previous/next matching
+# history entry.
+if [[ $ZSH_VERSION == (4.<4->*|<5->*) ]]; then
+    bindkey -M isearch '^P' history-incremental-pattern-search-backward
+    bindkey -M isearch '^N' history-incremental-pattern-search-forward
+fi
+
+# Automatically push cd-ed directories on the directory stack.
+setopt autopushd
+# Don't push duplicates on the directory stack.
+setopt pushdignoredups
+# Exchange the meaning of + and - when specifying a directory on the stack.
+# This way cd -<Tab> lists the last used directory first, which is more
+# natural because cd - goes to the last directory.
+setopt pushdminus
+
+
+# PROMPT SETTINGS
+
+# Use colorized output, necessary for prompts and completions.
+autoload -Uz colors; colors
+
+# Necessary for $EPOCHSECONDS, the UNIX time.
+zmodload zsh/datetime
+
+# Some shortcuts for colors. The %{...%} tells zsh that the data in between
+# doesn't need any space, necessary for correct prompt drawing. Use %F{color}
+# in more recent zsh versions (here compatibility is important).
+local red="%{${fg[red]}%}"
+local blue="%{${fg[blue]}%}"
+local green="%{${fg[green]}%}"
+local yellow="%{${fg[yellow]}%}"
+local default="%{${fg[default]}%}"
+
+# vcs_info was added in 4.3.9 but it works in earlier versions too. So load it
+# if the necessary files are available in ~/.zsh/functions/vcs_info (often a
+# symbolic link to current checkout of Zsh's sources).
+if [[ $ZSH_VERSION == (4.3.<9->*|4.<4->*|<5->*) ||
+      -d ~/.zsh/functions/vcs_info ]]; then
+    # Update fpath to allow loading the vcs_info functions.
+    if [[ -d ~/.zsh/functions/vcs_info ]]; then
+       fpath=(~/.zsh/functions/vcs_info/
+              ~/.zsh/functions/vcs_info/Backends
+              $fpath)
+    fi
+
+    # Load vcs_info to display information about version control repositories.
+    autoload -Uz vcs_info
+    # Only look for certain VCS.
+    zstyle ':vcs_info:*' enable git
+    # Check the repository for changes so they can be used in %u/%c (see
+    # below). This comes with a speed penalty for bigger repositories.
+    zstyle ':vcs_info:*' check-for-changes yes
+
+    # Set style of vcs_info display. The current branch (green) and VCS (blue)
+    # is displayed. If there is an special action going on (merge, rebase)
+    # it's also displayed (red). Also display if there are unstaged or staged
+    # (%u/%c) changes.
+    if [[ $ZSH_VERSION == (4.3.<11->*|4.<4->*|<5->*) ||
+          -d ~/.zsh/functions/vcs_info ]]; then
+        zstyle ':vcs_info:*' formats \
+            "(${green}%b%u%c${default}:${blue}%s${default}%m)" \
+            "${green}%u%c${default}"
+        zstyle ':vcs_info:*' actionformats \
+            "(${green}%b%u%c${default}/${red}%a${default}:${blue}%s${default}%m)" \
+            "${green}%u%c${default}"
+    else
+        # In older versions %u and %c are not defined yet and are not
+        # correctly expanded.
+        zstyle ':vcs_info:*' formats \
+            "(${green}%b${default}:${blue}%s${default})"
+        zstyle ':vcs_info:*' actionformats \
+            "(${green}%b${default}/${red}%a${default}:${blue}%s${default})"
+    fi
+    # Set style for formats/actionformats when unstaged (%u) and staged (%c)
+    # changes are detected in the repository; check-for-changes must be set to
+    # true for this to work. Thanks to Bart Trojanowski
+    # (http://jukie.net/~bart/blog/pimping-out-zsh-prompt) for the idea
+    # (2010-03-11 00:20 CET).
+    zstyle ':vcs_info:*' unstagedstr '¹'
+    zstyle ':vcs_info:*' stagedstr   '²'
+
+    # Default to run vcs_info. If possible we prevent running it later for
+    # speed reasons. If set to a non empty value vcs_info is run.
+    zshrc_force_run_vcs_info=1
+
+    # Cache system inspired by Bart Trojanowski
+    # (http://jukie.net/~bart/blog/pimping-out-zsh-prompt).
+    zstyle ':vcs_info:*+pre-get-data:*' hooks pre-get-data
+    +vi-pre-get-data() {
+        # Only Git and Mercurial support and need caching. Abort if any other
+        # VCS is used.
+        [[ $vcs != git && $vcs != hg ]] && return
+
+        # If the shell just started up or we changed directories (or for other
+        # custom reasons) we must run vcs_info.
+        if [[ -n $zshrc_force_run_vcs_info ]]; then
+            zshrc_force_run_vcs_info=
+            return
+        fi
+
+        # Don't run vcs_info by default to speed up the shell.
+        ret=1
+        # If a git/hg command was run then run vcs_info as the status might
+        # need to be updated.
+        case $(fc -ln $(($HISTCMD-1))) in
+            git* | g\ *)
+                ret=0
+                ;;
+            hg*)
+                ret=0
+                ;;
+        esac
+    }
+
+    # Display number of WIP stashes (this excludes manually named commits
+    # which might be used for something else), thanks to
+    # http://eseth.org/2010/git-in-zsh.html (viewed on 2013-04-27) for the
+    # idea to display the stash count.
+    function +vi-git-stashes() {
+        if [[ -s ${hook_com[base]/.git/refs/stash} ]]; then
+            local -a stashes
+            # Thanks to Valodim in #zsh on Freenode (2013-07-01 14:14 CEST)
+            # for the solution to "grep" the output with (M) and :#(...).
+            stashes=( ${(M)${(f)"$(git stash list 2>/dev/null)"}:#(*WIP*)} )
+
+            if [[ ${#stashes} -gt 0 ]]; then
+                hook_com[misc]+=" ${yellow}${#stashes}s${default}"
+            fi
+        fi
+    }
+
+    # Apply hooks to Git.
+    zstyle ':vcs_info:git*+set-message:*' hooks git-stashes
+
+    # Must run vcs_info when changing directories.
+    prompt_chpwd() {
+        zshrc_force_run_vcs_info=1
+    }
+    chpwd_functions+=(prompt_chpwd)
+
+    # Used by prompt code below to determine if vcs_info should be run.
+    zshrc_use_vcs_info=1
+else
+    zshrc_use_vcs_info=
+fi
+
+typeset -a zshrc_longrun_data
+zshrc_longrun_data=()
+# Display runtime in seconds for long running programs (> 60 seconds) and send
+# a bell to notify me.
+zshrc_longrun_preexec() {
+    local program=$3
+
+    # Handle fg.
+    local REPLY
+    zshrc_resolve_fg_to_resumed_job_name $program
+    program=$REPLY
+
+    # No background process found.
+    if [[ -z $program ]]; then
+        return
+    fi
+
+    # Don't track the time for certain (possible) long running processes which
+    # need no automatic notification.
+    local ignore
+    for ignore in elinks man mutt vim; do
+        case $program in
+            $ignore | $ignore\ *)
+                zshrc_longrun_data=()
+                return
+                ;;
+        esac
+    done
+
+    zshrc_longrun_data=($program $EPOCHSECONDS)
+}
+zshrc_longrun_precmd() {
+    # No previous timestamp available or disabled for this command, ignore.
+    if [[ -z $zshrc_longrun_data ]]; then
+        return
+    fi
+
+    local difference=$(( EPOCHSECONDS - zshrc_longrun_data[2] ))
+    if [[ $difference -gt 60 ]]; then
+        echo
+        echo -n "${fg[yellow]}"
+        echo -n "~> ${(V)zshrc_longrun_data[1]} took $difference seconds."
+        echo -n "${fg[default]}"
+        echo    "\a" # send bell
+    fi
+
+    # Clear status. Prevents displaying old status information when pressing
+    # enter with an empty command line.
+    zshrc_longrun_data=()
+}
+preexec_functions+=(zshrc_longrun_preexec)
+precmd_functions+=(zshrc_longrun_precmd)
+
+# Set the prompt. A two line prompt is used. On the top left the current
+# working directory is displayed, on the right vcs_info (if available) and the
+# current time in hex. On the bottom left current user name and host is shown,
+# the exit code of the last command if it wasn't 0, the number of running jobs
+# if not 0.
+#
+# The prompt is in green and blue to make easily detectable, the error exit
+# code in red and bold and the job count in yellow. Designed for dark
+# terminals.
+#
+# Thanks to Adam's prompt for the basic idea of this prompt.
+zshrc_prompt_precmd() {
+    # Regex to remove elements which take no space. Used to calculate the
+    # width of the top prompt. Thanks to Bart's and Adam's prompt code in
+    # Functions/Prompts/prompt_*_setup.
+    local zero='%([BSUbfksu]|([FB]|){*})'
+
+    # Call vcs_info before every prompt.
+    if [[ -n $zshrc_use_vcs_info ]]; then
+        vcs_info
+    else
+        vcs_info_msg_0_=
+        vcs_info_msg_1_=
+    fi
+
+    # Setup. Create variables holding the formatted content.
+
+    # Current directory in yellow, truncated if necessary (WIDTH is replaced
+    # below).
+    local directory="${yellow}%WIDTH<..<%~%<<${default}"
+    # Minimal information about the VCS, only displayed if there are
+    # unstaged/staged changes.
+    local vcs_staged=${vcs_info_msg_1_}
+
+    # Information about the VCS in this directory.
+    local vcs=${vcs_info_msg_0_}
+    # Current time (seconds since epoch) in Hex in bright blue.
+    local seconds="${blue}%B0x$(([##16] EPOCHSECONDS))%b${default}"
+
+    # User name (%n) in bright green.
+    local user="${green}%B%n%b${default}"
+    # Host name (%m) in bright green; underlined if running on a remote system
+    # through SSH.
+    local host="${green}%B%m%b${default}"
+    if [[ -n $SSH_CONNECTION ]]; then
+        host="%U${host}%u"
+    fi
+
+    # Number of background processes in yellow if not zero.
+    local background="%(1j.${yellow}%j${default}.)"
+    # Exit code in bright red in parentheses if not zero.
+    local exitcode="%(?..(${red}%B%?%b${default}%) )"
+    # Prompt symbol, % for normal users, # in red for root.
+    local symbol="%(!.${red}#${default}.%%)"
+
+    # Prefix characters in first and second line.
+    local top_prefix="${blue}%B.-%b${default}"
+    local bottom_prefix="${blue}%B'%b${default}"
+
+    # Combine them to create the prompt.
+
+    local top_left=${vcs_staged}
+    local top_right="${vcs}(${seconds})"
+
+    local width_top_prefix=${#${(S%%)top_prefix//$~zero/}}
+    local width_top_left=${#${(S%%)top_left//$~zero/}}
+    local width_top_right=${#${(S%%)top_right//$~zero/}}
+
+    # Calculate the maximum width of ${top_left}. -2 are the braces of
+    # ${top_left}, -1 is one separator from ${top_separator} (we want at least
+    # one between left and right parts).
+    local top_left_width_max=$((
+        COLUMNS - $width_top_prefix
+                - $width_top_left - 2
+                - 1
+                - $width_top_right
+    ))
+    # Truncate directory if necessary.
+    top_left="(${directory/WIDTH/${top_left_width_max}})${top_left}"
+    width_top_left=${#${(S%%)top_left//$~zero/}}
+
+    # Calculate the width of the top prompt to fill the middle with "-".
+    local width=$((
+        COLUMNS - width_top_prefix - width_top_left - width_top_right
+    ))
+    local top_separator="%B${blue}${(l:${width}::-:)}%b${default}"
+
+    PROMPT="${top_prefix}${top_left}${top_separator}${top_right}
+${bottom_prefix}${user}@${host} ${background}${symbol} ${exitcode}"
+}
+precmd_functions+=(zshrc_prompt_precmd)
+
+
+# When GNU screen, tmux, xterm or rxvt is used set the name of the window to
+# the currently running program.
+#
+# When a program is started preexec() sets the window's name to it; when it
+# stops precmd() resets the window's name to 'zsh'. 'fg' is supported and sets
+# the window's name to the resumed job.
+#
+# It works with GNU screen, tmux, xterm and rxvt.
+#
+# If a command is run with sudo or if the shell is running as root then a ! is
+# added at the beginning of the command to make this clear. If a command is
+# running on a different computer with ssh a @ is added at the beginning. If
+# screen/tmux is running on the remote machine instead of @screen @:hostname
+# (or @tmux ..; hostname replaced by the machine's hostname) is displayed.
+# This only works if the .zshrc on the server also uses this command.
+#
+# screen* is necessary as `screen` uses screen.linux for example for a linux
+# console.
+if [[ $TERM == screen* || $TERM == xterm* || $TERM == rxvt* ]]; then
+    # Is set to a non empty value to reset the window name in the next
+    # precmd() call.
+    zshrc_window_reset=yes
+
+    zshrc_window_preexec() {
+        # Get the program name with its arguments.
+        local program_name=$1
+
+        # When sudo is used, use real program name instead, but with an
+        # exclamation mark at the beginning (handled below).
+        local program_sudo=
+        if [[ $program_name == sudo* ]]; then
+            program_name=${program_name#sudo }
+            program_sudo=yes
+        fi
+
+        # Handle fg.
+        local REPLY
+        zshrc_resolve_fg_to_resumed_job_name $program_name
+        program_name=$REPLY
+
+        # Remove all arguments from the program name.
+        program_name=${program_name%% *}
+
+        # Ignore often used commands which are only running for a very short
+        # time. This prevents a "blinking" name when it's changed to "cd" for
+        # example and then some milliseconds later back to "zsh".
+        [[ $program_name == (cd*|d|ls|l|la|ll|clear|c) ]] && return
+
+        # Change my shortcuts so the real name of the program is displayed.
+        case $program_name in
+            e)
+                program_name=elinks
+                ;;
+            g)
+                program_name=git
+                ;;
+            m)
+                program_name=make
+                ;;
+            p)
+                program_name=less
+                ;;
+            v)
+                program_name=vim
+                ;;
+            mu)
+                program_name=mutt
+                ;;
+        esac
+
+        # Add an exclamation mark at the beginning if running with sudo or if
+        # running zsh as root.
+        if [[ -n $program_sudo || $UID -eq 0 ]]; then
+            program_name=!$program_name
+        fi
+
+        # Add an at mark at the beginning if running through ssh on a
+        # different computer.
+        if [[ -n $SSH_CONNECTION ]]; then
+            program_name="@$program_name"
+
+            # If screen is running in SSH then display "@:hostname" as title
+            # in the term/outer screen.
+            if [[ $program_name == @screen || $program_name == @tmux ]]; then
+                program_name="@:${HOST//.*/}"
+            # Use "@:!hostname" for root screens.
+            elif [[ $program_name == @!screen || $program_name == @!tmux ]]; then
+                program_name="@:!${HOST//.*/}"
+            fi
+        fi
+
+        # Set the window name to the currently running program.
+        zshrc_window_title $program_name
+
+        # Tell precmd() to reset the window name when the program stops.
+        zshrc_window_reset=yes
+    }
+
+    zshrc_window_precmd() {
+        # Abort if no window name reset is necessary.
+        [[ -z $zshrc_window_reset ]] && return
+
+        # Reset the window name to 'zsh'.
+        local name=zsh
+        # If the function was called with an argument then reset the window
+        # name to '.zsh' (used by clear alias).
+        if [[ -n $1 ]]; then
+            name=.zsh
+        fi
+
+        # Prepend prefixes like in zshrc_window_preexec().
+        if [[ $UID -eq 0 ]]; then
+            name="!$name"
+        fi
+        if [[ -n $SSH_CONNECTION ]]; then
+            name="@$name"
+        fi
+        zshrc_window_title $name
+
+        # Just reset the name, so no screen reset necessary for the moment.
+        zshrc_window_reset=
+    }
+
+    # Sets the window title. Works with GNU screen, tmux (which uses screen as
+    # TERM), xterm and rxvt. (V) escapes all non-printable characters, thanks
+    # to Mikachu in #zsh on Freenode (2010-08-07 17:09 CEST).
+    if [[ $TERM == screen* ]]; then
+        zshrc_window_title() {
+            print -n "\ek${(V)1}\e\\"
+        }
+    elif [[ $TERM == xterm* || $TERM == rxvt* ]]; then
+        zshrc_window_title() {
+            print -n "\e]2;${(V)1}\e\\"
+        }
+    else
+        # Fallback if another TERM is used.
+        zshrc_window_title() { }
+    fi
+
+    # Add the preexec() and precmd() hooks.
+    preexec_functions+=(zshrc_window_preexec)
+    precmd_functions+=(zshrc_window_precmd)
+else
+    # Fallback if another TERM is used, necessary to run screen (see below in
+    # "RUN COMMANDS").
+    zshrc_window_preexec() { }
+fi
+
+
+# COMPLETION SETTINGS
+
+# Load the complist module which provides additional features to completion
+# lists (coloring, scrolling).
+zmodload zsh/complist
+# Use new completion system, store dumpfile in ~/.zsh/cache to prevent
+# cluttering of ~/. $fpath must be set before calling this. Thanks to Adlai in
+# #zsh on Freenode (2009-08-07 21:05 CEST) for reminding me of the $fpath
+# problem.
+autoload -Uz compinit; compinit -d ~/.zsh/cache/zcompdump
+
+# Use cache to speed up some slow completions (dpkg, perl modules, etc.).
+zstyle ':completion:*' use-cache yes
+zstyle ':completion:*' cache-path ~/.zsh/cache
+
+# List all files in the current directory when pressing tab on an empty input,
+# behave like complete-word otherwise. Thanks to John Eikenberry [1] for the
+# code, read on 2014-03-15.
+#
+# [1]: http://unix.stackexchange.com/a/32426
+complete-word-or-complete-list-of-files() {
+    if [[ $#BUFFER == 0 ]]; then
+        BUFFER='ls '
+        CURSOR=3
+        zle list-choices
+        zle backward-kill-word
+    else
+        zle complete-word
+    fi
+}
+zle -N complete-word-or-complete-list-of-files
+# Let the completion system handle all completions, including expanding of
+# shell wildcards (which is handled by other shell mechanisms if the default
+# expand-or-complete is used).
+bindkey '^I' complete-word-or-complete-list-of-files
+# If there are multiple matches after pressing <Tab> always display them
+# immediately without requiring another <Tab>. a<Tab> completes to aa and
+# lists aaa, aab, aac as possible completions if the directory contains aaa,
+# aab, aac, bbb instead of only completing to aa.
+setopt nolistambiguous
+# Support completions in the middle of a word, without this option zsh jumps
+# to the end of the word before the completion process begins. Is required for
+# the _prefix completer.
+setopt completeinword
+
+# Force a reload of the completion system if nothing matched; this fixes
+# installing a program and then trying to tab-complete its name. Thanks to
+# Alex Munroe [1] for the code, read on 2014-03-03.
+#
+# [1]: https://github.com/eevee/rc/blob/master/.zshrc
+_force_rehash() {
+    if (( CURRENT == 1 )); then
+        rehash
+    fi
+    # We didn't really complete anything.
+    return 1
+}
+
+zstyle ':completion:::::' completer \
+    _force_rehash _expand _complete _prefix _ignored _approximate
+
+# Match specification to be tried when completing items. Each group ('...') is
+# tried after another if no matches were found, once matches are found no
+# other groups are tried. Thanks to Mikachu in #zsh on Freenode (2012-08-28
+# 18:48 CEST) for explanations.
+#
+# When matching also include the uppercase variant of typed characters
+# ('m:{a-z}={A-Z}'); using '' before this group would try the unmodified match
+# first, but I prefer to get all matches immediately (e.g. if Makefile and
+# makefile exist in the current directory echo m<tab> matches both, with '' it
+# would only match makefile because it found one match). This allows typing in
+# lowercase most of the time and completion fixes the case, which is faster.
+#
+# Don't perform these fixes in _approximate to prevent it from changing the
+# input too much. Thanks to the book "From Bash to Z Shell" page 249.
+zstyle ':completion:*:(^approximate):*' matcher-list 'm:{a-z}={A-Z}'
+
+# Allow one mistake per three characters. Thanks to the book "From Bash to Z
+# Shell" page 248.
+zstyle -e ':completion:*:approximate:*' max-errors \
+    'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'
+
+# Expand shell wildcards to all matching files after <Tab>. echo *<Tab>
+# results in a b c if the directory contains the files a, b, c. Thanks to the
+# book "From Bash to Z Shell" page 246.
+zstyle ':completion:*:expand:*' tag-order all-expansions
+# Keep prefixes unexpanded if possible: $HOME/<Tab> doesn't expand $HOME,
+# while $HOME<Tab> does.
+zstyle ':completion:*:expand:*' keep-prefix yes
+
+# When completing multiple path components display all matching ambiguous
+# components. For example /u/s/d/r/README<Tab> lists all matching READMEs
+# instead of just the matching paths up to the r/ component. Can be slow if
+# there are many matching files.
+zstyle ':completion:*' list-suffixes yes
+
+# Use ls-like colors for completions.
+zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
+
+# Make completion lists scrollable so "do you wish to see all n possibilities"
+# is no longer displayed. Display current position in percent (%p).
+zstyle ':completion:*:default' list-prompt '%p'
+# Display group name (%d) (like 'external command', 'alias', etc.), in bold.
+# Also display a message if _approximate found errors and no matches were
+# found.
+zstyle ':completion:*'             format '    %B%d%b:'
+zstyle ':completion:*:corrections' format '    %B%d%b (errors: %e)'
+zstyle ':completion:*:warnings'    format '    %Bno matches for %d%b'
+# Display different types of matches separately.
+zstyle ':completion:*' group-name ''
+
+# Separate man pages by section.
+zstyle ':completion:*' separate-sections yes
+
+# Don't draw trailing / in bold (new in zsh 4.3.11). Thanks to Mikachu in #zsh
+# on Freenode for the fix (2010-12-17 13:46 CET).
+zle_highlight=(suffix:none)
+
+# Ignore completion functions.
+zstyle ':completion:*:functions' ignored-patterns '_*'
+
+# When offering typo corrections, do not propose anything which starts with an
+# underscore (such as many of Zsh's shell functions). Thanks to paradigm [1]
+# for the idea (read on 2013-04-07).
+#
+# [1]: https://github.com/paradigm/dotfiles/blob/master/.zshrc
+CORRECT_IGNORE='_*'
+
+# Ignore parent directory.
+zstyle ':completion:*:(cd|mv|cp):*' ignore-parents parent pwd
+# Always complete file names only once in the current line. This makes it easy
+# to complete multiple file names because I can just press tab to get all
+# possible values. Otherwise I would have to skip the first value again and
+# again. Thanks to Mikachu in #zsh on Freenode (2011-08-11 14:42 CEST) for the
+# hint to use other. other is necessary so prefix<Tab> lists both prefix and
+# prefixrest if the directory contains prefix and prefixrest.
+zstyle ':completion:*:all-files' ignore-line other
+# Except for mv and cp, because I often want to use to similar names, so I
+# complete to the same and change it.
+zstyle ':completion:*:(mv|cp):all-files' ignore-line no
+
+# Don't complete ./config.* files, this makes running ./configure much
+# simpler. Thanks to Nomexous in #zsh on Freenode (2010-03-16 01:54 CET)
+zstyle ':completion:*:*:-command-:*' ignored-patterns './config.*'
+# Don't complete unwanted files with Vim. Thanks to Nomexous in #zsh on
+# Freenode (2010-06-06 04:54 CEST). See below for a way to complete them.
+zstyle ':completion:*:*:vim:*:all-files' ignored-patterns \
+    '*.aux' '*.log' '*.pdf' '*.bbl' '*.blg' '*.out' '*-blx.bib' '*.run.xml' \
+    '*.o' \
+    '*.pyc' \
+    '*.class'
+
+# Provide a fallback completer which always completes files. Useful when Zsh's
+# completion is too "smart". Thanks to Frank Terbeck <ft@bewatermyfriend.org>
+# (http://www.zsh.org/mla/users/2009/msg01038.html).
+zle -C complete-files complete-word _generic
+zstyle ':completion:complete-files:*' completer _files
+bindkey '^F' complete-files
+
+# Completion for my wrapper scripts.
+compdef slocate=locate
+compdef srsync=rsync
+compdef srsync-incremental=rsync
+compdef svalgrind=valgrind
+compdef sc=systemctl
+
+
+# CUSTOM ALIASES AND FUNCTIONS
+
+# If ^C is pressed while typing a command, add it to the history so it can be
+# easily retrieved later and then abort like ^C normally does. This is useful
+# when I want to abort an command to do something in between and then finish
+# typing the command.
+#
+# Thanks to Vadim Zeitlin <vz-zsh@zeitlins.org> for a fix (--) so lines
+# starting with - don't cause errors; and to Nadav Har'El
+# <nyh@math.technion.ac.il> for a fix (-r) to handle whitespace/quotes
+# correctly, both on the Zsh mailing list.
+TRAPINT() {
+    # Don't store this line in history if histignorespace is enabled and the
+    # line starts with a space.
+    if [[ -o histignorespace && ${BUFFER[1]} = ' ' ]]; then
+        return $1
+    fi
+
+    # Store the current buffer in the history.
+    zle && print -s -r -- $BUFFER
+
+    # Return the default exit code so Zsh aborts the current command.
+    return $1
+}
+
+# Load aliases and similar functions also used by other shells.
+if [[ -f ~/.shell/aliases ]]; then
+    . ~/.shell/aliases
+fi
+
+# Make sure aliases are expanded when using sudo.
+alias sudo='sudo '
+
+# Global aliases for often used redirections.
+alias -g E='2>&1'
+alias -g N='>/dev/null'
+alias -g EN='2>/dev/null'
+alias -g L='2>&1 | less'
+alias -g LS='2>&1 | less -S' # -S prevents wrapping of long lines
+alias -g D='2>&1 | colordiff | less'
+# Global aliases for often used commands.
+alias -g A='| awk'
+alias -g A1="| awk '{ print \$1 }'"
+alias -g A2="| awk '{ print \$2 }'"
+alias -g A3="| awk '{ print \$3 }'"
+alias -g G='| grep'
+alias -g GB='| grep -vE "^Binary file .+ matches\$"'
+alias -g H='| head'
+alias -g P='| perl'
+alias -g S='| sort'
+alias -g SL='| sort | less'
+alias -g T='| tail'
+alias -g U='| uniq'
+alias -g X='`xsel -p || xclip -o`' # X selection
+
+# Make going up directories simple.
+alias -g ...='../..'
+alias -g ....='../../..'
+alias -g .....='../../../..'
+
+# If the window naming feature is used (see above) then use ".zsh" (leading
+# dot) as title name after running clear so it's clear to me that the window
+# is empty. I open so much windows that I don't know in which I have something
+# important. This helps me to remember which windows are empty (I run clear
+# after I finished my work in a window).
+if [[ -n $zshrc_window_reset ]]; then
+    alias clear='clear; zshrc_window_reset=yes; zshrc_window_precmd reset'
+fi
+
+
+# CUSTOM COMMANDS
+
+# Display all branches (except stash) in gitk but only 200 commits as this is
+# much faster. Also put in the background and disown. Thanks to drizzd in #git
+# on Freenode (2010-04-03 17:55 CEST).
+(( $+commands[gitk] )) && gitk() {
+    command gitk --max-count=200 --branches --remotes --tags "$@" &
+    disown %command
+}
+# Same for tig (except the disown part as it's no GUI program).
+(( $+commands[tig] )) && tig() {
+    command tig --max-count=200 --branches --remotes --tags "$@"
+}
+
+# Choose the "best" PDF viewer available. Also setup completion for `pdf`.
+if (( $+commands[katarakt] )); then
+    pdf() {
+        command katarakt "$@" 2>/dev/null &
+        disown %command
+    }
+    # No completion for katarakt yet.
+    compdef pdf=xpdf
+elif (( $+commands[xpdf] )); then
+    pdf() {
+        command xpdf "$@" 2>/dev/null &
+        disown %command
+    }
+    compdef pdf=xpdf
+elif (( $+commands[zathura] )); then
+    pdf() {
+        command zathura "$@" 2>/dev/null &
+        disown %command
+    }
+    # No completion for zathura yet.
+    compdef pdf=xpdf
+fi
+
+
+# OS SPECIFIC SETTINGS
+
+if [[ $OSTYPE == linux* ]]; then
+    # Settings when creating Debian packages.
+    export DEBEMAIL=simon@ruderich.org
+    export DEBFULLNAME='Simon Ruderich'
+fi
+
+
+# LOAD ADDITIONAL CONFIGURATION FILES
+
+# Configuration options for rc.local.
+
+# Multiplexer to use. By default GNU screen is used. Possible values: screen,
+# tmux and empty (no multiplexer).
+zshrc_use_multiplexer=screen
+# Additional arguments for fortune.
+zshrc_fortune_arguments=()
+
+source_config ~/.zsh/rc.local
+
+
+# RUN COMMANDS
+
+# Make sure the multiplexer is available. Otherwise the exec terminates our
+# session.
+if [[ -n $zshrc_use_multiplexer ]]; then
+    if ! (( $+commands[$zshrc_use_multiplexer] )); then
+        echo "Multiplexer '$zshrc_use_multiplexer' not found." >&2
+        zshrc_use_multiplexer=
+    fi
+fi
+
+# If not already in screen or tmux, reattach to a running session or create a
+# new one. This also starts screen/tmux on a remote server when connecting
+# through ssh.
+if [[ $TERM != dumb && $TERM != dialup && $TERM != linux
+        && -z $STY && -z $TMUX ]]; then
+    # Get running detached sessions.
+    if [[ $zshrc_use_multiplexer = screen ]]; then
+        session=$(screen -list | grep 'Detached' | awk '{ print $1; exit }')
+    elif [[ $zshrc_use_multiplexer = tmux ]]; then
+        session=$(tmux list-sessions 2>/dev/null \
+                  | sed '/(attached)$/ d; s/^\([0-9]\{1,\}\).*$/\1/; q')
+    fi
+
+    # As we exec later we have to set the title here.
+    if [[ $zshrc_use_multiplexer = screen ]]; then
+        zshrc_window_preexec screen
+    elif [[ $zshrc_use_multiplexer = tmux ]]; then
+        zshrc_window_preexec tmux
+    fi
+
+    # Create a new session if none is running.
+    if [[ -z $session ]]; then
+        if [[ $zshrc_use_multiplexer = screen ]]; then
+            exec screen
+        elif [[ $zshrc_use_multiplexer = tmux ]]; then
+            exec tmux
+        fi
+    # Reattach to a running session.
+    else
+        if [[ $zshrc_use_multiplexer = screen ]]; then
+            exec screen -r $session
+        elif [[ $zshrc_use_multiplexer = tmux ]]; then
+            exec tmux attach-session -t $session
+        fi
+    fi
+fi
+
+# Colorize stderr in bold red. Very useful when looking for errors.
+if [[ $LD_PRELOAD != *libcoloredstderr.so* ]]; then
+    # coloredstderr found, use it.
+    if [[ -f ~/.zsh/libcoloredstderr.so ]]; then
+        export LD_PRELOAD="$HOME/.zsh/libcoloredstderr.so:$LD_PRELOAD"
+        export COLORED_STDERR_FDS=2,
+        export COLORED_STDERR_PRE=$'\033[91m' # bright red
+        export COLORED_STDERR_IGNORED_BINARIES=/usr/bin/tset
+    # Use the fallback solution.
+    #
+    # Thanks to http://gentoo-wiki.com/wiki/Zsh for the basic script and
+    # Mikachu in #zsh on Freenode (2010-03-07 04:03 CET) for some improvements
+    # (-r, printf). It's not yet perfect and doesn't work with su and git for
+    # example, but it can handle most interactive output quite well (even with
+    # no trailing new line) and in cases it doesn't work, the E alias can be
+    # used as workaround.
+    #
+    # Moved in the "run commands" section to prevent one unnecessary zsh
+    # process when starting GNU screen/tmux (see above).
+    else
+        exec 2>>(while read -r -k -u 0 line; do
+            printf '\e[91m%s\e[0m' $line
+            print -n $'\0'
+        done &)
+
+        # Reset doesn't work with this hack.
+        reset() {
+            command reset "$@" 2>&1
+        }
+    fi
+fi
+
+# Display possible log messages from ~/.xinitrc (if `xmessage` wasn't
+# installed). No race condition as xinitrc has finished before a shell is
+# executed and only one shell is started on login.
+if [[ -f ~/.xinitrc.errors ]]; then
+    echo "${fg_bold[red]}xinitrc failed!${fg_bold[default]}"
+    echo
+    cat ~/.xinitrc.errors
+    rm ~/.xinitrc.errors
+    echo
+fi
+
+# Run the following programs every 4 hours (and when zsh starts).
+PERIOD=14400
+periodic() {
+    # Display fortunes.
+    (( $+commands[fortune] )) && fortune -ac "${zshrc_fortune_arguments[@]}"
+    # Display reminders.
+    (( $+commands[rem] )) && [[ -f ~/.reminders ]] && rem -h
+}
+
+
+# RESTART SETTINGS
+
+zmodload -F zsh/stat b:zstat
+
+# Remember startup time. Used to perform automatic restarts when ~/.zshrc is
+# modified.
+zshrc_startup_time=$EPOCHSECONDS
+
+# Automatically restart Zsh if ~/.zshrc was modified.
+zshrc_restart_precmd() {
+    local stat
+    if ! zstat -A stat +mtime ~/.zshrc; then
+        return
+    fi
+
+    # ~/.zshrc wasn't modified, nothing to do.
+    if [[ $stat -le $zshrc_startup_time ]]; then
+        return
+    fi
+
+    local startup
+    strftime -s startup '%Y-%m-%d %H:%M:%S' $zshrc_startup_time
+
+    echo -n "${fg[magenta]}"
+    echo -n "~/.zshrc modified since startup ($startup) ... "
+    echo -n "${fg[default]}"
+
+    if [[ -n $zshrc_disable_restart ]]; then
+        echo 'automatic restart disabled.'
+        return
+    fi
+
+    # Don't exec if we have background processes because execing will let us
+    # lose control over them.
+    if [[ ${#${(k)jobstates}} -ne 0 ]]; then
+        echo 'active background jobs!'
+        return
+    fi
+
+    # Try to start a new interactive shell. If it fails, something is wrong.
+    # Don't kill our current session by execing it, abort instead.
+    zsh -i -c 'exit 42'
+    if [[ $? -ne 42 ]]; then
+        echo -n ${fg_bold[red]}
+        echo 'failed to start new zsh!'
+        echo -n ${fg_bold[default]}
+        return
+    fi
+
+    echo 'restarting zsh.'
+    echo
+
+    exec zsh
+}
+precmd_functions+=(zshrc_restart_precmd)
+
+
+# RELOAD SETTINGS
+
+zshenv_reload_time=0 # load before first command
+zshenv_boot_time=$(date -d "$(uptime -s)" '+%s') # uptime in epoch seconds
+
+# Automatically source ~/.zsh/env.update when the file changes (and exists).
+# Can be used e.g. to update SSH_AGENT_PID and GPG_AGENT_INFO variables in
+# running zsh processes. Sourced immediately before executing shell commands
+# (preexec) to ensure the environment is always up to date.
+zshenv_reload_preexec() {
+    local file
+    file=~/.zsh/env.update
+
+    local stat
+    if ! zstat -A stat +mtime $file 2>/dev/null; then
+        return
+    fi
+    # File was modified before reboot. Skip it to prevent loading of old
+    # values.
+    if [[ $stat -lt $zshenv_boot_time ]]; then
+        return
+    fi
+    # File wasn't modified, nothing to do.
+    if [[ $stat -le $zshenv_reload_time ]]; then
+        return
+    fi
+    zshenv_reload_time=$EPOCHSECONDS
+
+    unsetopt warn_create_global
+    . $file
+    setopt warn_create_global
+}
+preexec_functions+=(zshenv_reload_preexec)
+
+# vim: ft=zsh
diff --git a/vcs/.gitignore b/vcs/.gitignore
new file mode 100644 (file)
index 0000000..a296e88
--- /dev/null
@@ -0,0 +1,2 @@
+cvsrc
+gitconfig
diff --git a/vcs/Makefile b/vcs/Makefile
new file mode 100644 (file)
index 0000000..23d5991
--- /dev/null
@@ -0,0 +1,4 @@
+all:
+       @./setup.sh
+
+.PHONY: all
diff --git a/vcs/bin/tig.pl b/vcs/bin/tig.pl
new file mode 100755 (executable)
index 0000000..881583d
--- /dev/null
@@ -0,0 +1,126 @@
+#!/usr/bin/perl
+
+# tig-like git log output. Used when tig is not available or broken.
+
+# Copyright (C) 2013  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+use POSIX ();
+use Term::ANSIColor qw(colored);
+
+
+my $color_graph         = 'yellow';
+my $color_hash          = 'cyan';
+my $color_ref_sep       = 'cyan';
+my $color_ref_head      = 'cyan bold';
+my $color_ref_branch    = 'green bold';
+my $color_ref_reference = 'red bold';
+my $color_author        = 'magenta';
+
+
+# Aliases in Git with "! ..." are always run in the top-level-directory.
+# GIT_PREFIX contains the relative path to the current subdirectory. Thanks to
+# dr_lepper in #git on Freenode (2013-04-03 23:17 CEST) for telling me about
+# GIT_PREFIX.
+if (defined $ENV{GIT_PREFIX} and $ENV{GIT_PREFIX} ne '') {
+    chdir $ENV{GIT_PREFIX} or die $!;
+}
+
+my $format = '%x00'         # separator from --graph
+           . '%h'  . '%x00' # abbreviated commit hash
+           . '%at' . '%x00' # author date
+           . '%an' . '%x00' # author name
+           . '%s'  . '%x00' # subject
+           . '%d';          # ref names
+my @cmd = ('git', 'log', '--graph', "--format=$format",
+           # use either given arguments or --all to list all commits
+           (scalar @ARGV) ? @ARGV : '--all');
+open my $fh, '-|', @cmd or die $!;
+
+my $pager = $ENV{PAGER};
+# Try to find an usable pager without searching $PATH.
+if (not defined $pager) {
+    foreach my $path (qw(/usr/bin/less /bin/less /usr/bin/more /bin/more)) {
+        next if not -x $path;
+
+        $pager = $path;
+        last;
+    }
+}
+# Use a pager if STDOUT is a terminal.
+if (-t STDOUT and defined $pager) {
+    open STDOUT, '|-', $pager or die $!;
+}
+
+while (<$fh>) {
+    # History graph line.
+    if (m{^([|/\\_ ]+)$}) {
+        print colored($_, $color_graph);
+        next;
+    }
+
+    # Commit line.
+    /^([ *|.\\-]+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)\x00(.*)$/ or die $_;
+    my $prefix  = $1;
+    my $hash    = colored($2, $color_hash);
+    my $date    = POSIX::strftime('%Y-%m-%d', localtime($3));
+    my $author  = colored($4, $color_author);
+    my $message = $5;
+    my $refs    = $6;
+
+    # Strip trailing whitespace.
+    $prefix =~ s/\s+$//;
+    # Color "graph".
+    $prefix =~ s/\|/colored($&, $color_graph)/ge;
+
+    # Strip leading whitespace and braces.
+    $refs =~ s/^\s+//;
+    $refs =~ tr/()//d;
+
+    # Color refs.
+    $refs = join colored(', ', $color_ref_sep), map {
+        my $color;
+        if ($_ eq 'HEAD') {
+            $color = $color_ref_head;
+        } elsif (m{/}) {
+            $color = $color_ref_reference;
+        } else {
+            $color = $color_ref_branch;
+        }
+        colored($_, $color);
+    } split /, /, $refs;
+
+    if ($refs ne '') {
+        $refs = ' '
+              . colored('(', $color_ref_sep)
+              . $refs
+              . colored(')', $color_ref_sep);
+    }
+
+    printf "%s %s %s %s%s %s\n",
+           $prefix, $hash, $date, $author, $refs, $message;
+}
+
+close $fh or die $!;
+
+# Necessary for the redirection to a pager or the pager terminates after our
+# script finishes without displaying all data.
+if (defined $pager) {
+    close STDOUT or die $!;
+}
diff --git a/vcs/cvsrc.in b/vcs/cvsrc.in
new file mode 100644 (file)
index 0000000..90b11b4
--- /dev/null
@@ -0,0 +1,30 @@
+# CVS configuration file.
+
+# CVS doesn't support comments and newlines in ~/.cvsrc. They must be stripped
+# before using this file.
+
+# Copyright (C) 2011-2014  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Don't display all checked directories.
+cvs -q
+
+# Use unified diffs.
+diff -u
+# Create any directories which were removed locally.
+update -d
+
+# vim: ft=cvsrc
diff --git a/vcs/gitattributes b/vcs/gitattributes
new file mode 100644 (file)
index 0000000..8258ef8
--- /dev/null
@@ -0,0 +1,20 @@
+# Global Git configuration file for attributes.
+
+# Copyright (C) 2013  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+*.pdf diff=pdf
+*.gz diff=gzip
diff --git a/vcs/gitconfig.in b/vcs/gitconfig.in
new file mode 100644 (file)
index 0000000..50d88a9
--- /dev/null
@@ -0,0 +1,249 @@
+# Global Git configuration file.
+
+# Copyright (C) 2011-2017  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+[user]
+       name = Simon Ruderich
+       email = simon@ruderich.org
+
+[color]
+       ui = auto
+
+[color "diff"]
+       # Meta information.
+       meta = yellow bold
+       # Hunk header.
+       frag = magenta bold
+       # Function in hunk header.
+       func = blue bold
+       # Removed lines.
+       old = red bold
+       # Added lines.
+       new = green bold
+       # Commit headers.
+       commit = cyan
+
+[color "grep"]
+       # GNU grep-like colors.
+       filename = magenta
+       linenumber = green
+
+[core]
+       editor = vim
+       # Global gitattributes file. Thanks to canton7 in #git on Freenode
+       # (2011-11-09 13:23 CET).
+       attributesfile = PWD/gitattributes
+
+[pager]
+       # Use pager for the following commands.
+       status = true
+       tag = true
+
+[interactive]
+       # Don't require <Return> in interactive commands which require only a
+       # single key, for example `git add --patch`. Requires Perl module
+       # Term::Readkey.
+       singlekey = true
+
+[alias]
+       ## Shortcuts for often used commands.
+       #
+       ## Local.
+       c   = commit --verbose
+       ca  = commit --verbose --amend
+       cad = commit --verbose --amend --date=
+       d   = diff
+       dw  = diff --color-words
+       ds  = diff --stat
+       dc  = diff --cached
+       dcw = diff --cached --color-words
+       dcs = diff --cached --stat
+       g   = grep
+       gi  = grep --ignore-case
+       s   = status
+       l   = log
+       ls  = log --stat
+       lp  = log --patch
+       lpw = log --patch --color-words
+       ld  = show --date=short -s --pretty='format:%h (\"%s\", %ad)' # describe
+       a   = add
+       ap  = add --patch
+       au  = add --update
+       rs  = reset
+       rsh = reset --hard
+       rsp = reset --patch
+       rv  = revert
+       cl  = clean -ndx
+       clf = clean -fdx
+       ## Branches.
+       co  = checkout
+       b   = branch -a -v
+       br  = branch
+       m   = merge
+       mo  = merge origin/master
+       re  = rebase
+       rei = rebase --interactive
+       rec = rebase --continue
+       cp  = cherry-pick
+       ## Submodules.
+       sm  = submodule
+       ## Remote.
+       f   = fetch
+       t   = tag
+       p   = push
+       # Parallel git remote update. Also strips unnecessary output.
+       ru = "! git remote \
+             | xargs -d '\\n' -n1 -P0 git remote update 2>&1 \
+             | sed '/^$/d; \
+                    /^Please make sure you have the correct access rights$/d; \
+                    /^and the repository exists\\.$/d;'"
+       # Push to all remotes. Thanks to albel727 in #git on Freenode
+       # (2011-06-04 16:06 CEST) for the idea. Modified to push in parallel
+       # and to strip unnecessary output.
+       rp = "! git remote \
+             | xargs -d '\\n' -n1 -P0 git push 2>&1 \
+             | sed '/^$/d; \
+                    /^Please make sure you have the correct access rights$/d; \
+                    /^and the repository exists\\.$/d;'"
+       ## Patches.
+       fp  = format-patch
+       ## Maintenance.
+       # (Redirection of stderr is necessary to prevent missing output with
+       # my "color stderr" solution in Zsh.)
+       fs  = ! git fsck --strict --full 2>&1
+       fg  = ! git fs && git gc --aggressive 2>&1 # fsck and compress repo
+       ## Misc.
+       sl  = stash list
+       ss  = stash save
+       ssk = stash save --keep-index
+       ssu = stash save --include-untracked
+       sa  = stash apply --index
+       sp  = stash pop --index
+
+       ## Custom commands.
+       #
+       # tig-like log view. Similar to the following but with author/date
+       # information. --pretty=format is not used because it doesn't allow
+       # precise enough control over formats and colors.
+       #
+       # tig = log --pretty=oneline --graph --all --decorate --abbrev-commit
+       tig = ! PWD/bin/tig.pl
+
+       # Create backup of uncommitted and untracked changes.
+       ssb = "! git stash save --include-untracked \
+                    \"Backup on $(LANG=C date '+%a, %d %b %Y %H:%M:%S %z')\" \
+                    >/dev/null \
+             && git stash apply >/dev/null"
+
+       # Display list and content of untracked files. Untracked directories
+       # and symbolic links are only listed.
+       u = "! git ls-files --other --exclude-standard --directory -z \
+            | xargs -0 sh -c '\
+                  for x; do \
+                      printf \"\\033[1;33m-> %s\\033[0m:\" \"$x\"; \
+                      if test -d \"$x\"; then \
+                          echo \" directory\"; \
+                      elif test -h \"$x\"; then \
+                          echo \" symbolic link\"; \
+                      else \
+                          echo; \
+                          cat \"$x\"; \
+                      fi; \
+                      echo; \
+                  done' argv0 \
+            | less"
+
+[diff]
+       # Detect copies and renames.
+       renames = copy
+
+       # Diff algorithm to use.
+       algorithm = histogram
+
+       # Highlight moved code in a different color.
+       colorMoved = zebra
+
+       # Replace "a/" and "b/" prefix in diffs with characters describing the
+       # context (e.g. "i/"ndex and "w/"ork tree).
+       mnemonicprefix = true
+
+       # Change the definition of a word as used by diff --color-words to be
+       # shorter (not only spaces) and thus simplify the generated diffs.
+       # Words ([a-zA-Z0-9_]+) are matched, or a single non-word character
+       # ([^a-zA-Z0-9_]), therefore changes to words are shown in complete
+       # (e.g. from "word" to "newword" as "[-word-]{+newword+}"), but
+       # changes to non-word characters are shown character wise (e.g. from
+       # "==" to "!=" as "[-=-]{+!+}="); [-..-] is removal, {+..+} is
+       # addition. See t/ for some tests and examples.
+       wordRegex = [a-zA-Z0-9_]+|[^a-zA-Z0-9_]
+
+# Allow diffing of some binary files.
+#
+# "sh -c '..' ARGV0" is used when the programs require additional arguments
+# which are passed after ARGV0 by git.
+[diff "gzip"]
+       textconv = gzip -d -c
+[diff "pdf"]
+       textconv = sh -c 'exec pdftotext "$@" -' ARGV0
+[diff "sqlite"]
+       textconv = sh -c 'exec sqlite3 "$@" .dump' ARGV0
+
+[log]
+       # Display branches/tag names in log (same as log's --decorate option).
+       decorate = short
+       # If a single file is given to `git log`, automatically use --follow.
+       follow = true
+
+[merge]
+       tool = vimdiff
+
+       # Merge upstream branch if `git merge` is called without arguments.
+       defaultToUpstream = true
+
+[rebase]
+       # Use single-letter command names in git rebase -i which are faster to
+       # change.
+       abbreviateCommands = true
+
+[push]
+       # When running git push without a refspec push only the current
+       # branch, see man page git-config(1) for details. Default since Git
+       # 2.0.
+       default = simple
+
+[format]
+       # When using git format-patch use threads and add all patches as
+       # replies to the first one.
+       thread = shallow
+
+[transfer]
+       # Automatically fsck objects when receiving them (respected by git
+       # receive-pack and git fetch (>= 1.7.8, for fetch)).
+       fsckObjects = true
+
+[advice]
+       # Disable annoying advice messages.
+       waitingForEditor = false
+
+
+# NON-GIT SETTINGS
+
+[annex]
+       # My SSH config already uses ControlMaster where appropriate.
+       sshcaching = false
+
+# vim: ft=gitconfig
diff --git a/vcs/hgrc b/vcs/hgrc
new file mode 100644 (file)
index 0000000..ee4de57
--- /dev/null
+++ b/vcs/hgrc
@@ -0,0 +1,62 @@
+# This is the Mercurial configuration file.
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+[ui]
+username = Simon Ruderich <simon@ruderich.org>
+
+# Use git diffs with support for renames, binaries, access rights, etc.
+[diff]
+git = True
+
+[extensions]
+# Convert other vcs to mercurial.
+hgext.convert =
+# Simplify pull and merge processes.
+hgext.fetch =
+# Log output similar to hg view but as ASCII.
+hgext.graphlog =
+# Enable hg view.
+hgext.hgk =
+# Patch stack support.
+hgext.mq =
+# Use a pager for all output.
+hgext.pager =
+# Partial commit utility.
+hgext.record =
+# Allows cherry-picking and rebasing.
+hgext.transplant =
+
+# Necessary for hg view.
+[hgk]
+path = /usr/share/mercurial/hgk
+
+[hooks]
+# Precommit hook which runs tests if they exist.
+precommit = precommit-runtests
+# Prevent "hg pull" if MQ patches are applied.
+prechangegroup.mq-no-pull = ! hg qtop > /dev/null 2>&1
+# Prevent "hg push" if MQ patches are applied.
+preoutgoing.mq-no-push = ! hg qtop > /dev/null 2>&1
+
+# Use colordiff and less as pager so that output from diff is colored and
+# everything is easily readable in a terminal.
+[pager]
+pager = colordiff | less
+ignore = record, qrecord, view, clone
+
+# vim: ft=cfg
diff --git a/vcs/setup.sh b/vcs/setup.sh
new file mode 100755 (executable)
index 0000000..bf22f99
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# Setup script for VCS configuration files.
+
+# Copyright (C) 2011-2013  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+. ../lib.sh
+
+
+if installed git; then
+    generate gitconfig .in simple_cpp PWD -- "`pwd`"
+
+    # Older Git versions don't support push.default = simple.
+    if ! git status >/dev/null 2>&1; then
+        echo 'gitconfig: removing push.default = simple'
+        grep_i -v '^[[:space:]]default = simple$' gitconfig
+    fi
+    # Even older Git versions don't support color.function.
+    if ! git status >/dev/null 2>&1; then
+        echo 'gitconfig: removing color.function'
+        sed_i 's/^[[:space:]]*function = .*//' gitconfig
+    fi
+    # Even older Git versions don't support git log --patch but only -p.
+    if ! git log --patch >/dev/null 2>&1; then
+        echo 'gitconfig: replacing git log --patch with -p'
+        sed_i 's/log --patch/log -p/' gitconfig
+    fi
+
+    # If coloredstderr is used to color stderr then remove the workaround for
+    # missing output to stderr.
+    if test -n "${LD_PRELOAD:+set}" \
+            && printf '%s' "$LD_PRELOAD" | grep libcoloredstderr.so >/dev/null; then
+        echo 'gitconfig: removing stderr fix'
+        sed_i '/^\t\(fs\|fg\)  =/ s/2>&1//' gitconfig
+    fi
+
+    link gitconfig ~/.gitconfig
+fi
+
+if installed tig; then
+    if tig --version | grep -F 'tig version 1.' >/dev/null; then
+        link tigrc.old ~/.tigrc
+    else
+        link tigrc ~/.tigrc
+    fi
+fi
+
+if installed hg; then
+    link hgrc ~/.hgrc
+fi
+
+if installed cvs; then
+    # CVS doesn't support any comments nor empty lines in cvsrc.
+    grep -E -v '^#' cvsrc.in | grep -E -v '^$' >cvsrc
+
+    link cvsrc ~/.cvsrc
+fi
diff --git a/vcs/t/expected-empty.txt b/vcs/t/expected-empty.txt
new file mode 100644 (file)
index 0000000..19c91bf
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+====
+
+Short sentence with words!
+
+Longer sentence even more words, ain't that nice!
+
+And other one, just testing.
+
+option: new value
+option-two: new-value-two
+option-three: "value-three"
+
+function testme() {
+    firstCall();
+    while (a != b) {
+        if (!second_var) {
+            third_call() && fourth_call() \
+                || fifth_call();
+        }
+    }
+    return 42;
+}
+
+allow = $0 $! $? $.
+allow = $! $?
+allow = $0 $! $?
diff --git a/vcs/t/expected-nonspaces.txt b/vcs/t/expected-nonspaces.txt
new file mode 100644 (file)
index 0000000..d6b3558
--- /dev/null
@@ -0,0 +1,32 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+[-=====-]{+====+}
+
+[-Simple-]{+Short+} sentence with [-a few words.-]{+words!+}
+
+Longer sentence[-with-] even more [-words ..-]{+words,+} ain't that [-nice?-]{+nice!+}
+
+And [-another-]{+other+} one, just testing.
+
+option: {+new+} value
+option-two: [-value-two-]{+new-value-two+}
+option-three: [-value-three-]{+"value-three"+}
+
+function testme() {
+    [-first_call();-]
+[-    if-]{+firstCall();+}
+{+    while+} (a [-==-]{+!=+} b) {
+        if [-(!second_call())-]{+(!second_var)+} {
+            [-third_call();-]{+third_call() && fourth_call() \+}
+{+                || fifth_call();+}
+        }
+    }
+    return 42;
+}
+
+allow = {+$0+} $! $? $.
+allow = $! $?[-$.-]
+allow = {+$0+} $! $?[-$.-]
diff --git a/vcs/t/expected-word-nonword.txt b/vcs/t/expected-word-nonword.txt
new file mode 100644 (file)
index 0000000..76b34ac
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+====[-=-]
+
+S[-imple-]{+hort+} sentence with [-a few -]words[-.-]{+!+}
+
+Longer sentence [-with -]even more words[- ..-]{+,+} ain't that nice[-?-]{+!+}
+
+And [-an-]other one, just testing.
+
+option: {+new +}value
+option-two: {+new-+}value-two
+option-three: {+"+}value-three{+"+}
+
+function testme() {
+    first[-_c-]{+C+}all();
+    {+wh+}i[-f-]{+le+} (a [-=-]{+!+}= b) {
+        if (!second_{+var) {+}
+{+            third_+}call(){+ && fourth_call(+}) [-{-]{+\+}
+{+    +}            {+|| fif+}th[-ird-]_call();
+        }
+    }
+    return 42;
+}
+
+allow = ${+0 $+}! $? $.
+allow = $! $?[- $.-]
+allow = $[-!-]{+0+} $[-?-]{+!+} $[-.-]{+?+}
diff --git a/vcs/t/expected-words-nonword.txt b/vcs/t/expected-words-nonword.txt
new file mode 100644 (file)
index 0000000..5e0f6b1
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+====[-=-]
+
+[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+}
+
+Longer sentence [-with -]even more words[- ..-]{+,+} ain't that nice[-?-]{+!+}
+
+And [-another-]{+other+} one, just testing.
+
+option: {+new +}value
+option-two: {+new-+}value-two
+option-three: {+"+}value-three{+"+}
+
+function testme() {
+    [-first_call-]{+firstCall+}();
+    [-if-]{+while+} (a [-=-]{+!+}= b) {
+        if (![-second_call()-]{+second_var+}) {
+            third_call(){+ && fourth_call() \+}
+{+                || fifth_call()+};
+        }
+    }
+    return 42;
+}
+
+allow = ${+0 $+}! $? $.
+allow = $! $?[- $.-]
+allow = $[-!-]{+0+} $[-?-]{+!+} $[-.-]{+?+}
diff --git a/vcs/t/expected-words-nonwords-spaces.txt b/vcs/t/expected-words-nonwords-spaces.txt
new file mode 100644 (file)
index 0000000..cbc70dc
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+[-=====-]{+====+}
+
+[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+}
+
+Longer sentence [-with -]even more words[- .. -]{+, +}ain't that nice[-?-]{+!+}
+
+And [-another-]{+other+} one, just testing.
+
+option: {+new +}value
+option-two: {+new-+}value-two
+option-three[-: -]{+: "+}value-three{+"+}
+
+function testme() {
+    [-first_call-]{+firstCall+}();
+    [-if-]{+while+} (a[- == -]{+ != +}b) {
+        if (![-second_call()) {-]{+second_var) {+}
+            third_call{+() && fourth_call() \+}
+{+                || fifth_call+}();
+        }
+    }
+    return 42;
+}
+
+allow[- = $! $? $.-]{+ = $0 $! $? $.+}
+allow[- = $! $? $.-]{+ = $! $?+}
+allow[- = $! $? $.-]{+ = $0 $! $?+}
diff --git a/vcs/t/expected-words-nonwords.txt b/vcs/t/expected-words-nonwords.txt
new file mode 100644 (file)
index 0000000..cbc70dc
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+[-=====-]{+====+}
+
+[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+}
+
+Longer sentence [-with -]even more words[- .. -]{+, +}ain't that nice[-?-]{+!+}
+
+And [-another-]{+other+} one, just testing.
+
+option: {+new +}value
+option-two: {+new-+}value-two
+option-three[-: -]{+: "+}value-three{+"+}
+
+function testme() {
+    [-first_call-]{+firstCall+}();
+    [-if-]{+while+} (a[- == -]{+ != +}b) {
+        if (![-second_call()) {-]{+second_var) {+}
+            third_call{+() && fourth_call() \+}
+{+                || fifth_call+}();
+        }
+    }
+    return 42;
+}
+
+allow[- = $! $? $.-]{+ = $0 $! $? $.+}
+allow[- = $! $? $.-]{+ = $! $?+}
+allow[- = $! $? $.-]{+ = $0 $! $?+}
diff --git a/vcs/t/expected-words-nonwordspaces-spaces.txt b/vcs/t/expected-words-nonwordspaces-spaces.txt
new file mode 100644 (file)
index 0000000..11769da
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+[-=====-]{+====+}
+
+[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+}
+
+Longer sentence [-with -]even more words[- ..-]{+,+} ain't that nice[-?-]{+!+}
+
+And [-another-]{+other+} one, just testing.
+
+option: {+new +}value
+option-two: {+new-+}value-two
+option-three: {+"+}value-three{+"+}
+
+function testme() {
+    [-first_call-]{+firstCall+}();
+    [-if-]{+while+} (a [-==-]{+!=+} b) {
+        if (![-second_call())-]{+second_var)+} {
+            third_call{+() && fourth_call() \+}
+{+                || fifth_call+}();
+        }
+    }
+    return 42;
+}
+
+allow = {+$0 +}$! $? $.
+allow = $! $?[- $.-]
+allow = {+$0 +}$! $?[- $.-]
diff --git a/vcs/t/expected-words-nonwordspaces.txt b/vcs/t/expected-words-nonwordspaces.txt
new file mode 100644 (file)
index 0000000..ce5d927
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/test.txt b/test.txt
+--- a/test.txt
++++ b/test.txt
+@@ -1,26 +1,27 @@
+Tests
+[-=====-]{+====+}
+
+[-Simple-]{+Short+} sentence with[-a few-] words[-.-]{+!+}
+
+Longer sentence[-with-] even more words[-..-]{+,+} ain't that nice[-?-]{+!+}
+
+And [-another-]{+other+} one, just testing.
+
+option: {+new+} value
+option-two: {+new-+}value-two
+option-three: {+"+}value-three{+"+}
+
+function testme() {
+    [-first_call-]{+firstCall+}();
+    [-if-]{+while+} (a [-==-]{+!=+} b) {
+        if (![-second_call())-]{+second_var)+} {
+            third_call{+() && fourth_call() \+}
+{+                || fifth_call+}();
+        }
+    }
+    return 42;
+}
+
+allow = {+$0+} $! $? $.
+allow = $! $?[-$.-]
+allow = {+$0+} $! $?[-$.-]
diff --git a/vcs/t/test.sh b/vcs/t/test.sh
new file mode 100755 (executable)
index 0000000..6f1084b
--- /dev/null
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+# Small test file to check different --word-diff-regex settings in Git.
+
+# Copyright (C) 2012-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+git_diff() {
+    git diff --color=never --word-diff=plain --word-diff-regex="$1" \
+        | grep -v '^index ' >"result-$2.txt"
+    diff -u "../expected-$2.txt" "result-$2.txt"
+}
+
+
+# Setup test directory/files.
+mkdir test
+cd test
+
+git init >/dev/null
+cat >test.txt <<EOF
+Tests
+=====
+
+Simple sentence with a few words.
+
+Longer sentence with even more words .. ain't that nice?
+
+And another one, just testing.
+
+option: value
+option-two: value-two
+option-three: value-three
+
+function testme() {
+    first_call();
+    if (a == b) {
+        if (!second_call()) {
+            third_call();
+        }
+    }
+    return 42;
+}
+
+allow = \$! \$? \$.
+allow = \$! \$? \$.
+allow = \$! \$? \$.
+EOF
+git add test.txt
+git commit -m 'Initial commit.' >/dev/null
+
+cat >test.txt <<EOF
+Tests
+====
+
+Short sentence with words!
+
+Longer sentence even more words, ain't that nice!
+
+And other one, just testing.
+
+option: new value
+option-two: new-value-two
+option-three: "value-three"
+
+function testme() {
+    firstCall();
+    while (a != b) {
+        if (!second_var) {
+            third_call() && fourth_call() \\
+                || fifth_call();
+        }
+    }
+    return 42;
+}
+
+allow = \$0 \$! \$? \$.
+allow = \$! \$?
+allow = \$0 \$! \$?
+EOF
+
+
+git_diff '' empty
+
+git_diff '[^[:space:]]+' nonspaces
+
+git_diff '[a-zA-Z0-9_]|[^a-zA-Z0-9_]'    word-nonword
+git_diff '[a-zA-Z0-9_]+|[^a-zA-Z0-9_]'   words-nonword
+git_diff '[a-zA-Z0-9_]+|[^a-zA-Z0-9_]+'  words-nonwords
+git_diff '[a-zA-Z0-9_]+|[^a-zA-Z0-9_ ]+' words-nonwordspaces
+
+git_diff '[a-zA-Z0-9_]+|[^a-zA-Z0-9_]+|[ ]+'  words-nonwords-spaces
+git_diff '[a-zA-Z0-9_]+|[^a-zA-Z0-9_ ]+|[ ]+' words-nonwordspaces-spaces
+
+
+# Remove test directory after successful testing.
+rm -rf ../test
diff --git a/vcs/tigrc b/vcs/tigrc
new file mode 100644 (file)
index 0000000..59f9a7e
--- /dev/null
+++ b/vcs/tigrc
@@ -0,0 +1,103 @@
+# tig configuration file.
+
+# Copyright (C) 2011-2017  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Don't display uncommitted changes.
+set show-changes = no
+
+# Ignore case when searching.
+set ignore-case = yes
+
+# Don't write ~/.tig_history.
+set history-size = 0
+
+
+# DISPLAY
+
+# Same as the default, but use relative dates.
+set main-view = date:relative author:full commit-title:yes,graph,refs
+
+
+# BINDINGS
+
+# Allow moving in the main menu while displaying a diff in the bottom of the
+# screen.
+bind generic J next
+bind generic K previous
+
+# Mutt like bindings to move to first and last line.
+bind generic = move-first-line
+bind generic * move-last-line
+
+# Close current view like in mutt.
+bind diff i view-close
+
+# Unbind unnecessary views. I only use the main view and view diffs of
+# commits.
+bind generic m none
+bind generic d none
+bind generic l none
+bind generic t none
+bind generic f none
+bind generic b none
+bind generic r none
+bind generic s none
+bind generic S none
+bind generic c none
+bind generic y none
+bind generic g none
+bind generic p none
+# Unbind commands which may change the repository. I use tig only as a viewer.
+bind main C none
+
+
+# COLORS
+
+# Try to mimic gitk's colors.
+
+color date      default default
+color delimiter default default # ~ if text is too long
+
+# Main window.
+color cursor         black   cyan         # currently selected line
+color author         default default
+color graph-commit   magenta default      # commit dots in graph
+color main-head      green   default bold # HEAD
+color main-ref       green   default      # branches
+color main-remote    yellow  default      # remote branches
+color main-tag       yellow  default bold # tags
+color main-local-tag yellow  default bold # local tags (normal tags)
+
+# Information at the top of the commit diff.
+color commit                default default
+color "Author: "            default default
+color "Commit: "            default default
+color pp-merge              default default
+color "Date: "              default default
+color "AuthorDate: "        default default
+color "CommitDate: "        default default
+color pp-refs               default default
+# Special parts of the commit message.
+color "    Signed-off-by"   default default
+color "    Acked-by"        default default
+
+# Diff coloring.
+color diff-header default default bold # diff --git a/.. b/..
+color diff-index  default default bold # index abc..def
+color diff-chunk  cyan    default      # @@ -.. +.. @@
+
+# vim: ft=muttrc
diff --git a/vcs/tigrc.old b/vcs/tigrc.old
new file mode 100644 (file)
index 0000000..8824257
--- /dev/null
@@ -0,0 +1,104 @@
+# tig configuration file.
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Show the revision graph like gitk does.
+set show-rev-graph = yes
+
+# Use relative dates.
+set show-date = relative
+
+# Don't display uncommitted changes.
+set show-changes = no
+
+# Ignore case when searching.
+set ignore-case = yes
+
+
+# BINDINGS
+
+# Allow moving in the main menu while displaying a diff in the bottom of the
+# screen.
+bind generic J next
+bind generic K previous
+
+# Mutt like bindings to move to first and last line.
+bind generic = move-first-line
+bind generic * move-last-line
+
+# Close current view like in mutt.
+bind diff i view-close
+
+# Unbind unnecessary views. I only use the main view and view diffs of
+# commits.
+bind generic m none
+bind generic d none
+bind generic l none
+bind generic t none
+bind generic f none
+bind generic B none
+bind generic H none
+bind generic p none
+bind generic S none
+bind generic c none
+# Unbind commands which may change the repository. I use tig only as a viewer.
+bind generic C none
+bind generic u none
+bind generic ! none
+bind generic M none
+bind generic 1 none
+bind generic @ none
+bind generic e none
+bind generic G none
+
+
+# COLORS
+
+# Try to mimic gitk's colors.
+
+color date      default default
+color delimiter default default # ~ if text is too long
+
+# Main window.
+color cursor         black   cyan         # currently selected line
+color main-author    default default      # just 'author' in newer versions
+color graph-commit   magenta default      # commit dots in graph
+color main-head      green   default bold # HEAD
+color main-ref       green   default      # branches
+color main-remote    yellow  default      # remote branches
+color main-tag       yellow  default bold # tags
+color main-local-tag yellow  default bold # local tags (normal tags)
+
+# Information at the top of the commit diff.
+color commit    default default
+color pp-author default default
+color pp-commit default default
+color pp-merge  default default
+color pp-date   default default
+color pp-adate  default default
+color pp-cdate  default default
+color pp-refs   default default
+# Special parts of the commit message.
+color signoff   default default
+color acked     default default
+
+# Diff coloring.
+color diff-header default default bold # diff --git a/.. b/..
+color diff-index  default default bold # index abc..def
+color diff-chunk  cyan    default      # @@ -.. +.. @@
+
+# vim: ft=muttrc
diff --git a/vim/.gitignore b/vim/.gitignore
new file mode 100644 (file)
index 0000000..f0da910
--- /dev/null
@@ -0,0 +1,5 @@
+# Ignore unnecessary Vim files.
+/vim/bundle/*/doc/tags
+/vim/cache/
+/vim/doc/tags
+/vim/spell/
diff --git a/vim/Makefile b/vim/Makefile
new file mode 100644 (file)
index 0000000..23d5991
--- /dev/null
@@ -0,0 +1,4 @@
+all:
+       @./setup.sh
+
+.PHONY: all
diff --git a/vim/crontab b/vim/crontab
new file mode 100644 (file)
index 0000000..16b060e
--- /dev/null
@@ -0,0 +1,21 @@
+# Vim crontab entry.
+
+# Copyright (C) 2012  Simon Ruderich
+#
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Delete CtrlP cache files older than one day to force CtrlP to repopulate the
+# cache with current directory content.
+36 */8 * * * D="$HOME/.vim/cache/ctrlp"; test -d "$D" && find "$D" -name '\%*' -type f -mtime +1 -delete; true
diff --git a/vim/gvimrc b/vim/gvimrc
new file mode 100644 (file)
index 0000000..8d36ddf
--- /dev/null
@@ -0,0 +1,50 @@
+" GVim configuration file.
+
+" Copyright (C) 2011-2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Stop the cursor from blinking.
+set guicursor+=a:blinkon0
+
+" Don't display the menu.
+set guioptions-=m
+" Don't display the toolbar.
+set guioptions-=T
+" Don't display any scrollbars, they just waste space.
+set guioptions-=r
+set guioptions-=R
+set guioptions-=l
+set guioptions-=L
+
+" Increase window size to 110x25 if no tiling window manager is used.
+set columns=110
+set lines=25
+
+" Don't use the mouse.
+set mouse=
+" And don't use the mouse wheel.
+map <ScrollWheelUp>      <Nop>
+map <S-ScrollWheelUp>    <Nop>
+map <C-ScrollWheelUp>    <Nop>
+map <ScrollWheelDown>    <Nop>
+map <S-ScrollWheelDown>  <Nop>
+map <C-ScrollWheelDown>  <Nop>
+map <ScrollWheelLeft>    <Nop>
+map <S-ScrollWheelLeft>  <Nop>
+map <C-ScrollWheelLeft>  <Nop>
+map <ScrollWheelRight>   <Nop>
+map <S-ScrollWheelRight> <Nop>
+map <C-ScrollWheelRight> <Nop>
diff --git a/vim/setup.sh b/vim/setup.sh
new file mode 100755 (executable)
index 0000000..6884298
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# Setup script for Vim configuration files.
+
+# Copyright (C) 2011-2012  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+set -eu
+
+. ../lib.sh
+
+
+# Create directories.
+mkdir -p vim/cache
+
+# Create documentation tags for pathogen plugins. `vim -e` always exists with
+# 1 for unknown reasons.
+vim -e -c ':call pathogen#helptags()' -c ':q' || true
+
+# Link setup.
+link vim ~/.vim
+link vimrc ~/.vimrc
+if installed gvim; then
+    link gvimrc ~/.gvimrc
+fi
+
+# Create/Update custom spell checking files.
+if test -f vim/spell/Makefile; then
+    make -C vim/spell
+fi
+
+if test -d ~/.crontab.d; then
+    link crontab ~/.crontab.d/crontab.dotfiles-vim
+fi
diff --git a/vim/term2gui.pl b/vim/term2gui.pl
new file mode 100755 (executable)
index 0000000..274ad2c
--- /dev/null
@@ -0,0 +1,313 @@
+#!/usr/bin/perl
+
+# Convert a terminal color scheme for 256 color terminals to a GUI color
+# scheme by adding the appropriate gui* options.
+
+# Copyright (C) 2012-2014  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+sub xterm2rgb {
+    my ($color) = @_;
+
+    # Taken from the urxvt-8.2-256color.patch in Debian's urxvt-unicode
+    # package 9.07-2.
+    my @colors = (
+        'rgb:00/00/00',
+        'rgb:00/00/5f',
+        'rgb:00/00/87',
+        'rgb:00/00/af',
+        'rgb:00/00/d7',
+        'rgb:00/00/ff',
+        'rgb:00/5f/00',
+        'rgb:00/5f/5f',
+        'rgb:00/5f/87',
+        'rgb:00/5f/af',
+        'rgb:00/5f/d7',
+        'rgb:00/5f/ff',
+        'rgb:00/87/00',
+        'rgb:00/87/5f',
+        'rgb:00/87/87',
+        'rgb:00/87/af',
+        'rgb:00/87/d7',
+        'rgb:00/87/ff',
+        'rgb:00/af/00',
+        'rgb:00/af/5f',
+        'rgb:00/af/87',
+        'rgb:00/af/af',
+        'rgb:00/af/d7',
+        'rgb:00/af/ff',
+        'rgb:00/d7/00',
+        'rgb:00/d7/5f',
+        'rgb:00/d7/87',
+        'rgb:00/d7/af',
+        'rgb:00/d7/d7',
+        'rgb:00/d7/ff',
+        'rgb:00/ff/00',
+        'rgb:00/ff/5f',
+        'rgb:00/ff/87',
+        'rgb:00/ff/af',
+        'rgb:00/ff/d7',
+        'rgb:00/ff/ff',
+        'rgb:5f/00/00',
+        'rgb:5f/00/5f',
+        'rgb:5f/00/87',
+        'rgb:5f/00/af',
+        'rgb:5f/00/d7',
+        'rgb:5f/00/ff',
+        'rgb:5f/5f/00',
+        'rgb:5f/5f/5f',
+        'rgb:5f/5f/87',
+        'rgb:5f/5f/af',
+        'rgb:5f/5f/d7',
+        'rgb:5f/5f/ff',
+        'rgb:5f/87/00',
+        'rgb:5f/87/5f',
+        'rgb:5f/87/87',
+        'rgb:5f/87/af',
+        'rgb:5f/87/d7',
+        'rgb:5f/87/ff',
+        'rgb:5f/af/00',
+        'rgb:5f/af/5f',
+        'rgb:5f/af/87',
+        'rgb:5f/af/af',
+        'rgb:5f/af/d7',
+        'rgb:5f/af/ff',
+        'rgb:5f/d7/00',
+        'rgb:5f/d7/5f',
+        'rgb:5f/d7/87',
+        'rgb:5f/d7/af',
+        'rgb:5f/d7/d7',
+        'rgb:5f/d7/ff',
+        'rgb:5f/ff/00',
+        'rgb:5f/ff/5f',
+        'rgb:5f/ff/87',
+        'rgb:5f/ff/af',
+        'rgb:5f/ff/d7',
+        'rgb:5f/ff/ff',
+        'rgb:87/00/00',
+        'rgb:87/00/5f',
+        'rgb:87/00/87',
+        'rgb:87/00/af',
+        'rgb:87/00/d7',
+        'rgb:87/00/ff',
+        'rgb:87/5f/00',
+        'rgb:87/5f/5f',
+        'rgb:87/5f/87',
+        'rgb:87/5f/af',
+        'rgb:87/5f/d7',
+        'rgb:87/5f/ff',
+        'rgb:87/87/00',
+        'rgb:87/87/5f',
+        'rgb:87/87/87',
+        'rgb:87/87/af',
+        'rgb:87/87/d7',
+        'rgb:87/87/ff',
+        'rgb:87/af/00',
+        'rgb:87/af/5f',
+        'rgb:87/af/87',
+        'rgb:87/af/af',
+        'rgb:87/af/d7',
+        'rgb:87/af/ff',
+        'rgb:87/d7/00',
+        'rgb:87/d7/5f',
+        'rgb:87/d7/87',
+        'rgb:87/d7/af',
+        'rgb:87/d7/d7',
+        'rgb:87/d7/ff',
+        'rgb:87/ff/00',
+        'rgb:87/ff/5f',
+        'rgb:87/ff/87',
+        'rgb:87/ff/af',
+        'rgb:87/ff/d7',
+        'rgb:87/ff/ff',
+        'rgb:af/00/00',
+        'rgb:af/00/5f',
+        'rgb:af/00/87',
+        'rgb:af/00/af',
+        'rgb:af/00/d7',
+        'rgb:af/00/ff',
+        'rgb:af/5f/00',
+        'rgb:af/5f/5f',
+        'rgb:af/5f/87',
+        'rgb:af/5f/af',
+        'rgb:af/5f/d7',
+        'rgb:af/5f/ff',
+        'rgb:af/87/00',
+        'rgb:af/87/5f',
+        'rgb:af/87/87',
+        'rgb:af/87/af',
+        'rgb:af/87/d7',
+        'rgb:af/87/ff',
+        'rgb:af/af/00',
+        'rgb:af/af/5f',
+        'rgb:af/af/87',
+        'rgb:af/af/af',
+        'rgb:af/af/d7',
+        'rgb:af/af/ff',
+        'rgb:af/d7/00',
+        'rgb:af/d7/5f',
+        'rgb:af/d7/87',
+        'rgb:af/d7/af',
+        'rgb:af/d7/d7',
+        'rgb:af/d7/ff',
+        'rgb:af/ff/00',
+        'rgb:af/ff/5f',
+        'rgb:af/ff/87',
+        'rgb:af/ff/af',
+        'rgb:af/ff/d7',
+        'rgb:af/ff/ff',
+        'rgb:d7/00/00',
+        'rgb:d7/00/5f',
+        'rgb:d7/00/87',
+        'rgb:d7/00/af',
+        'rgb:d7/00/d7',
+        'rgb:d7/00/ff',
+        'rgb:d7/5f/00',
+        'rgb:d7/5f/5f',
+        'rgb:d7/5f/87',
+        'rgb:d7/5f/af',
+        'rgb:d7/5f/d7',
+        'rgb:d7/5f/ff',
+        'rgb:d7/87/00',
+        'rgb:d7/87/5f',
+        'rgb:d7/87/87',
+        'rgb:d7/87/af',
+        'rgb:d7/87/d7',
+        'rgb:d7/87/ff',
+        'rgb:d7/af/00',
+        'rgb:d7/af/5f',
+        'rgb:d7/af/87',
+        'rgb:d7/af/af',
+        'rgb:d7/af/d7',
+        'rgb:d7/af/ff',
+        'rgb:d7/d7/00',
+        'rgb:d7/d7/5f',
+        'rgb:d7/d7/87',
+        'rgb:d7/d7/af',
+        'rgb:d7/d7/d7',
+        'rgb:d7/d7/ff',
+        'rgb:d7/ff/00',
+        'rgb:d7/ff/5f',
+        'rgb:d7/ff/87',
+        'rgb:d7/ff/af',
+        'rgb:d7/ff/d7',
+        'rgb:d7/ff/ff',
+        'rgb:ff/00/00',
+        'rgb:ff/00/5f',
+        'rgb:ff/00/87',
+        'rgb:ff/00/af',
+        'rgb:ff/00/d7',
+        'rgb:ff/00/ff',
+        'rgb:ff/5f/00',
+        'rgb:ff/5f/5f',
+        'rgb:ff/5f/87',
+        'rgb:ff/5f/af',
+        'rgb:ff/5f/d7',
+        'rgb:ff/5f/ff',
+        'rgb:ff/87/00',
+        'rgb:ff/87/5f',
+        'rgb:ff/87/87',
+        'rgb:ff/87/af',
+        'rgb:ff/87/d7',
+        'rgb:ff/87/ff',
+        'rgb:ff/af/00',
+        'rgb:ff/af/5f',
+        'rgb:ff/af/87',
+        'rgb:ff/af/af',
+        'rgb:ff/af/d7',
+        'rgb:ff/af/ff',
+        'rgb:ff/d7/00',
+        'rgb:ff/d7/5f',
+        'rgb:ff/d7/87',
+        'rgb:ff/d7/af',
+        'rgb:ff/d7/d7',
+        'rgb:ff/d7/ff',
+        'rgb:ff/ff/00',
+        'rgb:ff/ff/5f',
+        'rgb:ff/ff/87',
+        'rgb:ff/ff/af',
+        'rgb:ff/ff/d7',
+        'rgb:ff/ff/ff',
+        'rgb:08/08/08',
+        'rgb:12/12/12',
+        'rgb:1c/1c/1c',
+        'rgb:26/26/26',
+        'rgb:30/30/30',
+        'rgb:3a/3a/3a',
+        'rgb:44/44/44',
+        'rgb:4e/4e/4e',
+        'rgb:58/58/58',
+        'rgb:62/62/62',
+        'rgb:6c/6c/6c',
+        'rgb:76/76/76',
+        'rgb:80/80/80',
+        'rgb:8a/8a/8a',
+        'rgb:94/94/94',
+        'rgb:9e/9e/9e',
+        'rgb:a8/a8/a8',
+        'rgb:b2/b2/b2',
+        'rgb:bc/bc/bc',
+        'rgb:c6/c6/c6',
+        'rgb:d0/d0/d0',
+        'rgb:da/da/da',
+        'rgb:e4/e4/e4',
+        'rgb:ee/ee/ee',
+    );
+
+    return if $color < 16 or $color > 255; # undef
+
+    my $value = $colors[$color - 16];
+    $value =~ s{^rgb:}{};
+    $value =~ s{/}{}g;
+
+    return '#' . $value;
+}
+
+
+while (<STDIN>) {
+    # Only handle lines with highlight commands.
+    if (/^\s*\bhi(?:ghlight)?\b/) {
+        foreach my $setting (m/\bcterm(?:fg|bg)?=\S+/g) {
+            my ($name, $value) = split /=/, $setting;
+
+            my $gui_name = $name;
+            $gui_name =~ s/cterm/gui/;
+
+            my $new_value;
+            if ($name eq 'cterm') {
+                $new_value = $value;
+            } elsif ($value eq 'NONE') {
+                $new_value = 'NONE';
+            } else {
+                $new_value = xterm2rgb($value);
+            }
+
+            # Update existing value.
+            if (/\b\Q$gui_name\E=/) {
+                s/\Q$gui_name\E=\S+/$gui_name=$new_value/;
+            # Append at the end of the line.
+            } else {
+                s/\n/ $gui_name=$new_value\n/;
+            }
+        }
+    }
+
+    print;
+}
diff --git a/vim/vim/after/ftplugin/mail.vim b/vim/vim/after/ftplugin/mail.vim
new file mode 100644 (file)
index 0000000..8d46f5a
--- /dev/null
@@ -0,0 +1,46 @@
+" Vim filetype plugin file
+"
+" Language:     Mail
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2009-2013  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Use only 65 characters per line as given in rfc1855.
+setlocal textwidth=65
+
+" Remove trailing whitespace after quotes.
+silent! %s/^>.\{-}\zs\s\+$//
+" Remove spaces between quotes (> > to >>).
+silent! %s/^>\+\zs >/>/g
+silent! %s/^>\+\zs >/>/g
+silent! %s/^>\+\zs >/>/g
+
+" Move directly after the headers.
+normal! gg
+normal! }
+" And if the mail contains a reply move the cursor after the quote.
+if search('^On .\+ wrote:$', 'n')
+    normal! }
+endif
+
+" Fold quotes. Thanks to Teemu Likonen <tlikonen@iki.fi>
+" (http://permalink.gmane.org/gmane.editors.vim.devel/20890,
+" <20080809190407.GA7584@mithlond.arda.local>) and danielsh_ in #mutt on
+" Freenode (2010-07-10 13:01 CEST) for letting me know.
+setlocal foldmethod=expr foldminlines=2
+setlocal foldexpr=strlen(substitute(substitute(getline(v:lnum),'\\s','','g'),'[^>].*','',''))
diff --git a/vim/vim/after/ftplugin/php.vim b/vim/vim/after/ftplugin/php.vim
new file mode 100644 (file)
index 0000000..1c37b1e
--- /dev/null
@@ -0,0 +1,25 @@
+" Vim filetype plugin file
+"
+" Language:     PHP
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2008-2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Automatically fix my wrong usage of kdb tags in phpdoc comments which don't
+" exist and should be kbd tags. I make this typo all the time.
+abbreviate <buffer> kdb kbd
diff --git a/vim/vim/after/syntax/apache.vim b/vim/vim/after/syntax/apache.vim
new file mode 100644 (file)
index 0000000..474b5e6
--- /dev/null
@@ -0,0 +1,24 @@
+" Vim syntax file
+"
+" Language:     Apache files
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2008-2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Only check spelling in comments.
+syn match apacheComment "^\s*#.*$" contains=apacheFixme,@Spell
diff --git a/vim/vim/after/syntax/c.vim b/vim/vim/after/syntax/c.vim
new file mode 100644 (file)
index 0000000..4af58da
--- /dev/null
@@ -0,0 +1,27 @@
+" Vim syntax file
+"
+" Language:     C
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Highlight statement control keywords differently when my color scheme is
+" used.
+if exists('g:colors_name') && g:colors_name == 'simon'
+    syntax keyword statementControl continue break return goto
+endif
diff --git a/vim/vim/after/syntax/crontab.vim b/vim/vim/after/syntax/crontab.vim
new file mode 100644 (file)
index 0000000..1d12828
--- /dev/null
@@ -0,0 +1,24 @@
+" Vim syntax file
+"
+" Language:     Crontab files
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2008-2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Don't check spelling in variables.
+syntax match crontabVar "^\s*\k\w*\s*="me=e-1 contains=@NoSpell
diff --git a/vim/vim/after/syntax/diff.vim b/vim/vim/after/syntax/diff.vim
new file mode 100644 (file)
index 0000000..7815f08
--- /dev/null
@@ -0,0 +1,35 @@
+" Vim syntax file
+"
+" Language:     Diff
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Color added/removed lines in the diff header the same color as added/removed
+" lines.
+syntax match diffAdded   /^+++ .*$/
+syntax match diffRemoved /^--- .*$/
+" Dedicated group for hunks.
+syntax match diffHunk    /^@.*$/ contains=diffSubname
+
+" Special colors for filename and hunk.
+highlight diffFile    ctermfg=yellow  cterm=bold  guifg=yellow  gui=bold
+highlight diffHunk    ctermfg=magenta cterm=bold  guifg=magenta gui=bold
+" Added lines in green, removed lines in red.
+highlight diffAdded   ctermfg=green   cterm=bold  guifg=green   gui=bold
+highlight diffRemoved ctermfg=red     cterm=bold  guifg=red     gui=bold
diff --git a/vim/vim/after/syntax/gitcommit.vim b/vim/vim/after/syntax/gitcommit.vim
new file mode 100644 (file)
index 0000000..f4ec7a3
--- /dev/null
@@ -0,0 +1,25 @@
+" Vim syntax file
+"
+" Language:     Git commit messages
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Don't fold diffs in Git commit messages. I want to fold the list of
+" committed files, but take a closer look at the diffs.
+syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ contains=@gitcommitDiff
diff --git a/vim/vim/after/syntax/perl.vim b/vim/vim/after/syntax/perl.vim
new file mode 100644 (file)
index 0000000..7a45bc1
--- /dev/null
@@ -0,0 +1,39 @@
+" Vim syntax file
+"
+" Language:     Perl
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012-2014  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Use SpecialComment to highlight shebangs.
+highlight link perlSharpBang SpecialComment
+
+" I never use continue and break, and always confuse them with next and last.
+syntax match Error "\<\(continue\|break\)\>"
+
+" Highlight statement control keywords differently when my color scheme is
+" used.
+if exists('g:colors_name') && g:colors_name == 'simon'
+    highlight link perlStatementControl statementControl
+endif
+
+" Highlight for Inline::C in __DATA__/__END__ section
+unlet b:current_syntax
+syntax include @InlineC syntax/c.vim
+syntax region perlInlineC start='^__C__$' skip='.' end='.' contains=@InlineC
+syntax cluster perlDATA add=perlInlineC
diff --git a/vim/vim/after/syntax/vim.vim b/vim/vim/after/syntax/vim.vim
new file mode 100644 (file)
index 0000000..1943d3c
--- /dev/null
@@ -0,0 +1,25 @@
+" Vim syntax file
+"
+" Language:     Vim .vim files
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2008-2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Fix for the default .vim syntax to also recognize "syntax default" instead
+" of "syntax def".
+syn region vimHiLink   contained oneline matchgroup=vimCommand start="\<\(def\(ault\)\?\s\+\)\=link\>\|\<def\>" end="$"        contains=vimHiGroup,vimGroup,vimHLGroup,vimNotation
diff --git a/vim/vim/autoload/pathogen.vim b/vim/vim/autoload/pathogen.vim
new file mode 100644 (file)
index 0000000..7b89cca
--- /dev/null
@@ -0,0 +1,326 @@
+" pathogen.vim - path option manipulation
+" Maintainer:   Tim Pope <http://tpo.pe/>
+" Version:      2.2
+
+" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
+"
+" For management of individually installed plugins in ~/.vim/bundle (or
+" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
+" .vimrc is the only other setup necessary.
+"
+" The API is documented inline below.  For maximum ease of reading,
+" :set foldmethod=marker
+
+if exists("g:loaded_pathogen") || &cp
+  finish
+endif
+let g:loaded_pathogen = 1
+
+function! s:warn(msg)
+  echohl WarningMsg
+  echomsg a:msg
+  echohl NONE
+endfunction
+
+" Point of entry for basic default usage.  Give a relative path to invoke
+" pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke
+" pathogen#surround().  For backwards compatibility purposes, a full path that
+" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories()
+" instead.
+function! pathogen#infect(...) abort " {{{1
+  for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}']
+    if path =~# '^[^\\/]\+$'
+      call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
+      call pathogen#incubate(path . '/{}')
+    elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$'
+      call pathogen#incubate(path)
+    elseif path =~# '[\\/]\%({}\|\*\)$'
+      call pathogen#surround(path)
+    else
+      call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
+      call pathogen#surround(path . '/{}')
+    endif
+  endfor
+  call pathogen#cycle_filetype()
+  return ''
+endfunction " }}}1
+
+" Split a path into a list.
+function! pathogen#split(path) abort " {{{1
+  if type(a:path) == type([]) | return a:path | endif
+  let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
+  return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
+endfunction " }}}1
+
+" Convert a list to a path.
+function! pathogen#join(...) abort " {{{1
+  if type(a:1) == type(1) && a:1
+    let i = 1
+    let space = ' '
+  else
+    let i = 0
+    let space = ''
+  endif
+  let path = ""
+  while i < a:0
+    if type(a:000[i]) == type([])
+      let list = a:000[i]
+      let j = 0
+      while j < len(list)
+        let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
+        let path .= ',' . escaped
+        let j += 1
+      endwhile
+    else
+      let path .= "," . a:000[i]
+    endif
+    let i += 1
+  endwhile
+  return substitute(path,'^,','','')
+endfunction " }}}1
+
+" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
+function! pathogen#legacyjoin(...) abort " {{{1
+  return call('pathogen#join',[1] + a:000)
+endfunction " }}}1
+
+" Remove duplicates from a list.
+function! pathogen#uniq(list) abort " {{{1
+  let i = 0
+  let seen = {}
+  while i < len(a:list)
+    if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
+      call remove(a:list,i)
+    elseif a:list[i] ==# ''
+      let i += 1
+      let empty = 1
+    else
+      let seen[a:list[i]] = 1
+      let i += 1
+    endif
+  endwhile
+  return a:list
+endfunction " }}}1
+
+" \ on Windows unless shellslash is set, / everywhere else.
+function! pathogen#separator() abort " {{{1
+  return !exists("+shellslash") || &shellslash ? '/' : '\'
+endfunction " }}}1
+
+" Convenience wrapper around glob() which returns a list.
+function! pathogen#glob(pattern) abort " {{{1
+  let files = split(glob(a:pattern),"\n")
+  return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
+endfunction "}}}1
+
+" Like pathogen#glob(), only limit the results to directories.
+function! pathogen#glob_directories(pattern) abort " {{{1
+  return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
+endfunction "}}}1
+
+" Turn filetype detection off and back on again if it was already enabled.
+function! pathogen#cycle_filetype() " {{{1
+  if exists('g:did_load_filetypes')
+    filetype off
+    filetype on
+  endif
+endfunction " }}}1
+
+" Check if a bundle is disabled.  A bundle is considered disabled if it ends
+" in a tilde or its basename or full name is included in the list
+" g:pathogen_disabled.
+function! pathogen#is_disabled(path) " {{{1
+  if a:path =~# '\~$'
+    return 1
+  elseif !exists("g:pathogen_disabled")
+    return 0
+  endif
+  let sep = pathogen#separator()
+  let blacklist = g:pathogen_disabled
+  return index(blacklist, strpart(a:path, strridx(a:path, sep)+1)) != -1 && index(blacklist, a:path) != 1
+endfunction "}}}1
+
+" Prepend the given directory to the runtime path and append its corresponding
+" after directory.  If the directory is already included, move it to the
+" outermost position.  Wildcards are added as is.  Ending a path in /{} causes
+" all subdirectories to be added (except those in g:pathogen_disabled).
+function! pathogen#surround(path) abort " {{{1
+  let sep = pathogen#separator()
+  let rtp = pathogen#split(&rtp)
+  if a:path =~# '[\\/]{}$'
+    let path = fnamemodify(a:path[0:-4], ':p:s?[\\/]\=$??')
+    let before = filter(pathogen#glob_directories(path.sep.'*'), '!pathogen#is_disabled(v:val)')
+    let after  = filter(reverse(pathogen#glob_directories(path.sep."*".sep."after")), '!pathogen#is_disabled(v:val[0:-7])')
+    call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
+  else
+    let path = fnamemodify(a:path, ':p:s?[\\/]\=$??')
+    let before = [path]
+    let after = [path . sep . 'after']
+    call filter(rtp, 'index(before + after, v:val) == -1')
+  endif
+  let &rtp = pathogen#join(before, rtp, after)
+  return &rtp
+endfunction " }}}1
+
+" Prepend all subdirectories of path to the rtp, and append all 'after'
+" directories in those subdirectories.  Deprecated.
+function! pathogen#runtime_prepend_subdirectories(path) " {{{1
+  call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#surround('.string(a:path.'/{}').')')
+  return pathogen#surround(a:path . pathogen#separator() . '{}')
+endfunction " }}}1
+
+" For each directory in the runtime path, add a second entry with the given
+" argument appended.  If the argument ends in '/{}', add a separate entry for
+" each subdirectory.  The default argument is 'bundle/{}', which means that
+" .vim/bundle/*, $VIM/vimfiles/bundle/*, $VIMRUNTIME/bundle/*,
+" $VIM/vim/files/bundle/*/after, and .vim/bundle/*/after will be added (on
+" UNIX).
+function! pathogen#incubate(...) abort " {{{1
+  let sep = pathogen#separator()
+  let name = a:0 ? a:1 : 'bundle/{}'
+  if "\n".s:done_bundles =~# "\\M\n".name."\n"
+    return ""
+  endif
+  let s:done_bundles .= name . "\n"
+  let list = []
+  for dir in pathogen#split(&rtp)
+    if dir =~# '\<after$'
+      if name =~# '{}$'
+        let list +=  filter(pathogen#glob_directories(substitute(dir,'after$',name[0:-3],'').'*'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
+      else
+        let list += [dir, substitute(dir, 'after$', '', '') . name . sep . 'after']
+      endif
+    else
+      if name =~# '{}$'
+        let list +=  [dir] + filter(pathogen#glob_directories(dir.sep.name[0:-3].'*'), '!pathogen#is_disabled(v:val)')
+      else
+        let list += [dir . sep . name, dir]
+      endif
+    endif
+  endfor
+  let &rtp = pathogen#join(pathogen#uniq(list))
+  return 1
+endfunction " }}}1
+
+" Deprecated alias for pathogen#incubate().
+function! pathogen#runtime_append_all_bundles(...) abort " {{{1
+  if a:0
+    call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#incubate('.string(a:1.'/{}').')')
+  else
+    call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#incubate()')
+  endif
+  return call('pathogen#incubate', map(copy(a:000),'v:val . "/{}"'))
+endfunction
+
+let s:done_bundles = ''
+" }}}1
+
+" Invoke :helptags on all non-$VIM doc directories in runtimepath.
+function! pathogen#helptags() abort " {{{1
+  let sep = pathogen#separator()
+  for glob in pathogen#split(&rtp)
+    for dir in split(glob(glob), "\n")
+      if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
+        silent! execute 'helptags' pathogen#fnameescape(dir.'/doc')
+      endif
+    endfor
+  endfor
+endfunction " }}}1
+
+command! -bar Helptags :call pathogen#helptags()
+
+" Execute the given command.  This is basically a backdoor for --remote-expr.
+function! pathogen#execute(...) abort " {{{1
+  for command in a:000
+    execute command
+  endfor
+  return ''
+endfunction " }}}1
+
+" Like findfile(), but hardcoded to use the runtimepath.
+function! pathogen#runtime_findfile(file,count) abort "{{{1
+  let rtp = pathogen#join(1,pathogen#split(&rtp))
+  let file = findfile(a:file,rtp,a:count)
+  if file ==# ''
+    return ''
+  else
+    return fnamemodify(file,':p')
+  endif
+endfunction " }}}1
+
+" Backport of fnameescape().
+function! pathogen#fnameescape(string) abort " {{{1
+  if exists('*fnameescape')
+    return fnameescape(a:string)
+  elseif a:string ==# '-'
+    return '\-'
+  else
+    return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
+  endif
+endfunction " }}}1
+
+if exists(':Vedit')
+  finish
+endif
+
+let s:vopen_warning = 0
+
+function! s:find(count,cmd,file,lcd) " {{{1
+  let rtp = pathogen#join(1,pathogen#split(&runtimepath))
+  let file = pathogen#runtime_findfile(a:file,a:count)
+  if file ==# ''
+    return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
+  endif
+  if !s:vopen_warning
+    let s:vopen_warning = 1
+    let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
+  else
+    let warning = ''
+  endif
+  if a:lcd
+    let path = file[0:-strlen(a:file)-2]
+    execute 'lcd `=path`'
+    return a:cmd.' '.pathogen#fnameescape(a:file) . warning
+  else
+    return a:cmd.' '.pathogen#fnameescape(file) . warning
+  endif
+endfunction " }}}1
+
+function! s:Findcomplete(A,L,P) " {{{1
+  let sep = pathogen#separator()
+  let cheats = {
+        \'a': 'autoload',
+        \'d': 'doc',
+        \'f': 'ftplugin',
+        \'i': 'indent',
+        \'p': 'plugin',
+        \'s': 'syntax'}
+  if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
+    let request = cheats[a:A[0]].a:A[1:-1]
+  else
+    let request = a:A
+  endif
+  let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
+  let found = {}
+  for path in pathogen#split(&runtimepath)
+    let path = expand(path, ':p')
+    let matches = split(glob(path.sep.pattern),"\n")
+    call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
+    call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
+    for match in matches
+      let found[match] = 1
+    endfor
+  endfor
+  return sort(keys(found))
+endfunction " }}}1
+
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve       :execute s:find(<count>,'edit<bang>',<q-args>,0)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit    :execute s:find(<count>,'edit<bang>',<q-args>,0)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen    :execute s:find(<count>,'edit<bang>',<q-args>,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit   :execute s:find(<count>,'split',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit  :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit   :execute s:find(<count>,'pedit',<q-args>,<bang>1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread    :execute s:find(<count>,'read',<q-args>,<bang>1)
+
+" vim:set et sw=2:
diff --git a/vim/vim/bundle/ctrlp b/vim/vim/bundle/ctrlp
new file mode 160000 (submodule)
index 0000000..b5d3fe6
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit b5d3fe66a58a13d2ff8b6391f4387608496a030f
diff --git a/vim/vim/bundle/deb/autoload/deb.vim b/vim/vim/bundle/deb/autoload/deb.vim
new file mode 100644 (file)
index 0000000..9e6fd1e
--- /dev/null
@@ -0,0 +1,258 @@
+" Vim autoload file for browsing debian package.
+" copyright (C) 2007-2008, arno renevier <arenevier@fdn.fr>
+" Distributed under the GNU General Public License (version 2 or above)
+" Last Change: 2008 april 1
+" 
+" Inspired by autoload/tar.vim by Charles E Campbell
+"
+" Latest version of that file can be found at
+" http://www.fdn.fr/~arenevier/vim/autoload/deb.vim
+" It should also be available at
+" http://www.vim.org/scripts/script.php?script_id=1970
+
+if &cp || exists("g:loaded_deb") || v:version < 700
+    finish
+endif
+let g:loaded_deb= "v1.4"
+
+fun! deb#read(debfile, member)
+
+    " checks if ar and tar are installed
+    if !s:hascmd("ar") || !s:hascmd("tar")
+        return
+    endif
+
+    let l:target = a:member
+
+    let l:archmember = s:dataFileName(a:debfile) " default archive member to extract
+    if l:archmember == ""
+        echohl WarningMsg | echo "***error*** (deb#read) no valid data file found in debian archive"
+        return
+    elseif l:archmember == "data.tar.gz"
+        let l:unpcmp = "tar zxfO "
+    elseif l:archmember == "data.tar.bz2"
+        let l:unpcmp = "tar jxfO "
+    elseif l:archmember == "data.tar.lzma"
+        if !s:hascmd("lzma")
+            return
+        endif
+        let l:unpcmp = "lzma -d | tar xfO "
+    elseif l:archmember == "data.tar"
+        let l:unpcmp = "tar xfO "
+    endif
+
+    if a:member =~ '^\* ' " information control file
+        let l:archmember = "control.tar.gz"
+        let l:target = substitute(l:target, "^\* ", "", "")
+        let l:unpcmp = "tar zxfO "
+    elseif a:member =~ ' -> ' " symbolic link
+        let l:target = split(a:member,' -> ')[0]
+        let l:linkname = split(a:member,' -> ')[1]
+
+        if l:linkname =~ "^\/" " direct symlink: path is already absolute
+            let l:target = ".".l:linkname
+
+        else 
+        " transform relative path to absolute path
+
+            " first, get basename for target
+            let l:target = substitute(l:target, "\/[^/]*$", "", "")
+
+            " while it begins with ../
+            while l:linkname =~ "^\.\.\/" 
+
+                " removes one level of ../ in linkname
+                let l:linkname = substitute(l:linkname, "^\.\.\/", "", "")
+
+                " go one directory up in target
+                let l:target = substitute(l:target, "\/[^/]*$", "", "")
+            endwhile
+
+            let l:target = l:target."/".l:linkname
+        endif
+    endif
+    
+    " we may preprocess some files (such as man pages, or changelogs)
+    let l:preproccmd = ""
+        
+    "
+    " unzip man pages
+    "
+    if l:target =~ "\.\/usr\/share\/man\/.*\.gz$"
+        
+        " try to fail gracefully if a command is not available
+        if !s:hascmd("gzip")
+            return
+        elseif !s:hascmd("nroff") 
+            let l:preproccmd = "| gzip -cd"
+        elseif !s:hascmd("col")
+            let l:preproccmd = "| gzip -cd | nroff -mandoc"
+        else
+            let l:preproccmd = "| gzip -cd | nroff -mandoc | col -b"
+        endif
+    
+    "
+    " unzip other .gz files
+    "
+    elseif l:target =~ '.*\.gz$'
+        if !s:hascmd("gzip")
+            return
+        endif
+        let l:preproccmd = "| gzip -cd"
+    endif
+
+    " read content
+    exe "silent r! ar p " . s:QuoteFile(a:debfile) . " " . s:QuoteFile(l:archmember) . " | " . l:unpcmp . " - " . s:QuoteFile(l:target) . l:preproccmd
+    " error will be treated in calling function
+    if v:shell_error != 0
+        return
+    endif
+
+    exe "file deb:".l:target
+
+    0d
+
+    setlocal nomodifiable nomodified readonly
+
+endfun
+
+fun! deb#browse(file)
+
+    " checks if necessary utils are installed
+    if !s:hascmd("dpkg") || !s:hascmd("ar") || !s:hascmd("tar")
+        return
+    endif
+
+    " checks if file is readable
+    if !filereadable(a:file)
+        return
+    endif
+    if a:file =~ "'"
+        echohl WarningMsg | echo "***error*** (deb#Browse) filename cannot contain quote character (" . a:file . ")"
+        return
+    endif
+
+    let keepmagic = &magic
+    set magic
+
+    " set filetype to "deb"
+    set ft=deb
+
+    setlocal modifiable noreadonly
+
+    " set header
+    exe "$put ='".'\"'." deb.vim version ".g:loaded_deb."'"
+    exe "$put ='".'\"'." Browsing debian package ".a:file."'"
+    $put=''
+
+    " package info
+    "exe "silent read! dpkg -I ".a:file
+    "$put=''
+
+    " display information control files
+    let l:infopos = line(".")
+    exe "silent read! ar p " . s:QuoteFile(a:file) . " control.tar.gz | tar zt"
+
+    $put=''
+
+    " display data files
+    let l:listpos = line(".")
+    exe "silent read! dpkg -c ". s:QuoteFile(a:file)
+
+    " format information control list
+    " removes '* ./' line
+    exe (l:infopos + 1). 'd'
+    " add a star before each line
+    exe "silent " . (l:infopos + 1). ',' . (l:listpos - 2) . 's/^/\* /'
+    
+    " format data list
+    exe "silent " . l:listpos . ',$s/^.*\s\(\.\/\(\S\|\).*\)$/\1/'
+    
+    if v:shell_error != 0
+        echohl WarningMsg | echo "***warning*** (deb#Browse) error when listing content of " . a:file
+        let &magic = keepmagic
+        return
+    endif
+
+    0d
+
+    setlocal nomodifiable readonly
+    noremap <silent> <buffer> <cr> :call <SID>DebBrowseSelect()<cr>
+    let &magic = keepmagic
+
+endfun
+
+fun! s:DebBrowseSelect()
+    let l:fname= getline(".")
+
+    " sanity check
+    if (l:fname !~ '^\.\/') && (l:fname !~ '^\* \.\/')
+        return
+    endif
+    if l:fname =~ "'"
+        echohl WarningMsg | echo "***error*** (DebBrowseSelect) filename cannot contain quote character (" . l:fname . ")"
+        return
+    endif
+
+    " do nothing on directories
+    " TODO: find a way to detect symlinks to directories, to be able not to
+    " open them
+    if (l:fname =~ '\/$')
+        return
+    endif
+
+    " need to get it now since a new window will open
+    let l:curfile= expand("%")
+   
+    " open new window
+    new
+    wincmd _
+
+    call deb#read(l:curfile, l:fname)
+
+    if v:shell_error != 0
+        echohl WarningMsg | echo "***warning*** (DebBrowseSelect) error when reading " . l:fname
+        return
+    endif
+
+    filetype detect
+
+    " zipped files, are unziped in deb#read, but filetype may not
+    " automatically work.
+    if l:fname =~ "\.\/usr\/share\/man\/.*\.gz$"
+        set filetype=man
+    elseif l:fname =~ "\.\/usr\/share\/doc\/.*\/changelog.Debian.gz$"
+        set filetype=debchangelog
+    endif
+
+endfun
+
+" return data file name for debian package. This can be either data.tar.gz,
+" data.tar.bz2 or data.tar.lzma
+fun s:dataFileName(deb)
+    for fn in ["data.tar.gz", "data.tar.bz2", "data.tar.lzma", "data.tar"]
+        " [0:-2] is to remove trailing null character from command output
+        if (system("ar t " . "'" . a:deb . "'" . " " . fn))[0:-2] == fn
+            return fn
+        endif
+    endfor
+    return "" " no debian data format in this archive
+endfun
+
+fun s:QuoteFile(file)
+    " we need to escape %, #, <, and >
+    " see :help cmdline-specialk
+    return "'" .  substitute(a:file, '\([%#<>]\)', '\\\1', 'g') . "'"
+endfun
+
+" return 1 if cmd exists
+" display error message and return 0 otherwise
+fun s:hascmd(cmd)
+    if executable(a:cmd)
+        return 1
+    else
+        echohl Error | echo "***error*** " . a:cmd . " not available on your system"
+        return 0
+    else
+endfu
+
diff --git a/vim/vim/bundle/deb/plugin/debPlugin.vim b/vim/vim/bundle/deb/plugin/debPlugin.vim
new file mode 100644 (file)
index 0000000..4ae2f13
--- /dev/null
@@ -0,0 +1,18 @@
+" debPlugin.vim -- a Vim plugin for browsing debian packages
+" copyright (C) 2007, arno renevier <arenevier@fdn.fr>
+" Distributed under the GNU General Public License (version 2 or above)
+" Last Change: 2007 December 07
+"
+" This file only sets the autocommands. Functions are in autoload/deb.vim.
+"
+" Latest version of that file can be found at
+" http://www.fdn.fr/~arenevier/vim/plugin/debPlugin.vim
+" It should also be available at
+" http://www.vim.org/scripts/script.php?script_id=1970
+"
+if &cp || exists("g:loaded_debPlugin") || !has("unix") || v:version < 700
+    finish
+endif
+let g:loaded_debPlugin = 1
+
+autocmd BufReadCmd   *.deb             call deb#browse(expand("<amatch>"))
diff --git a/vim/vim/bundle/deb/syntax/deb.vim b/vim/vim/bundle/deb/syntax/deb.vim
new file mode 100644 (file)
index 0000000..4ad6af1
--- /dev/null
@@ -0,0 +1,28 @@
+" Vim syntax file for browsing debian package.
+" copyright (C) 2007, arno renevier <arenevier@fdn.fr>
+" Distributed under the GNU General Public License (version 2 or above)
+" Last Change: 2007 December 07
+"
+" Latest version of that file can be found at
+" http://www.fdn.fr/~arenevier/vim/syntax/deb.vim
+" It should also be available at
+" http://www.vim.org/scripts/script.php?script_id=1970
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn match debComment '^".*'
+syn match debInfoFilename '^\* \.\/.*'
+syn match debDataFilename '^\.\/.*[^/]$'
+syn match debDirname '^\..*\/$'
+syn match debSymlink '^\.\/.* -> .*$' contains=debSymlinkTarget,debSymlinkArrow,debSymlinkName
+syn match debSymlinkName '^\S*' contained
+syn match debSymlinkTarget '\S*$' contained
+syn match debSymlinkArrow '->' contained
+
+hi def link debComment Comment
+hi def link debInfoFilename Type
+hi def link debDataFilename PreProc
+hi def link debSymlinkName Identifier
+hi def link debSymlinkTarget PreProc
diff --git a/vim/vim/bundle/fswitch b/vim/vim/bundle/fswitch
new file mode 160000 (submodule)
index 0000000..e716da1
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit e716da1ee6f80ee859b36083e6d6c3d7617b72e7
diff --git a/vim/vim/bundle/gundo b/vim/vim/bundle/gundo
new file mode 160000 (submodule)
index 0000000..531f996
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 531f996bfec59d0addfe102b16538e54f6a2111b
diff --git a/vim/vim/bundle/matchit/doc/matchit.txt b/vim/vim/bundle/matchit/doc/matchit.txt
new file mode 100644 (file)
index 0000000..8a3a96e
--- /dev/null
@@ -0,0 +1,406 @@
+*matchit.txt*   Extended "%" matching
+
+For instructions on installing this file, type
+       :help matchit-install
+inside Vim.
+
+For Vim version 6.3.  Last change:  2007 Aug 29
+
+
+                 VIM REFERENCE MANUAL    by Benji Fisher
+
+*matchit* *matchit.vim*
+
+1. Extended matching with "%"                          |matchit-intro|
+2. Activation                                          |matchit-activate|
+3. Configuration                                       |matchit-configure|
+4. Supporting a New Language                           |matchit-newlang|
+5. Known Bugs and Limitations                          |matchit-bugs|
+
+The functionality mentioned here is a plugin, see |add-plugin|.
+This plugin is only available if 'compatible' is not set.
+You can avoid loading this plugin by setting the "loaded_matchit" variable
+in your |vimrc| file: >
+       :let loaded_matchit = 1
+
+{Vi does not have any of this}
+
+==============================================================================
+1. Extended matching with "%"                          *matchit-intro*
+
+                                                       *matchit-%*
+%      Cycle forward through matching groups, such as "if", "else", "endif",
+       as specified by |b:match_words|.
+
+                                                       *g%* *v_g%* *o_g%*
+g%     Cycle backwards through matching groups, as specified by
+       |b:match_words|.  For example, go from "if" to "endif" to "else".
+
+                                                       *[%* *v_[%* *o_[%*
+[%     Go to [count] previous unmatched group, as specified by
+       |b:match_words|.  Similar to |[{|.
+
+                                                       *]%* *v_]%* *o_]%*
+]%     Go to [count] next unmatched group, as specified by
+       |b:match_words|.  Similar to |]}|.
+
+                                                       *v_a%*
+a%     In Visual mode, select the matching group, as specified by
+       |b:match_words|, containing the cursor.  Similar to |v_a[|.
+       A [count] is ignored, and only the first character of the closing
+       pattern is selected.
+
+In Vim, as in plain vi, the percent key, |%|, jumps the cursor from a brace,
+bracket, or paren to its match.  This can be configured with the 'matchpairs'
+option.  The matchit plugin extends this in several ways:
+
+           You can match whole words, such as "if" and "endif", not just
+       single characters.  You can also specify a |regular-expression|.
+           You can define groups with more than two words, such as "if",
+       "else", "endif".  Banging on the "%" key will cycle from the "if" to
+       the first "else", the next "else", ..., the closing "endif", and back
+       to the opening "if".  Nested structures are skipped.  Using |g%| goes
+       in the reverse direction.
+           By default, words inside comments and strings are ignored, unless
+       the cursor is inside a comment or string when you type "%".  If the
+       only thing you want to do is modify the behavior of "%" so that it
+       behaves this way, you do not have to define |b:match_words|, since the
+       script uses the 'matchpairs' option as well as this variable.
+
+See |matchit-details| for details on what the script does, and |b:match_words|
+for how to specify matching patterns.
+
+MODES:                 *matchit-modes* *matchit-v_%* *matchit-o_%*
+
+Mostly, % and related motions (|g%| and |[%| and |]%|) work just like built-in
+|motion| commands in |Operator-pending| and |Visual| modes.  However, you
+cannot make these motions |linewise| or |characterwise|, since the |:omap|s
+that define them start with "v" in order to make the default behavior
+inclusive.  (See |o_v|.)  In other words, "dV%" will not work.  The
+work-around is to go through Visual mode:  "V%d" will work.
+
+LANGUAGES:                                     *matchit-languages*
+
+Currently, the following languages are supported:  Ada, ASP with VBS, Csh,
+DTD, Entity, Essbase, Fortran, HTML, JSP (same as HTML), LaTeX, Lua, Pascal,
+SGML, Shell, Tcsh, Vim, XML.  Other languages may already have support via
+the default |filetype-plugin|s in the standard vim distribution.
+
+To support a new language, see |matchit-newlang| below.
+
+DETAILS:                               *matchit-details* *matchit-parse*
+
+Here is an outline of what matchit.vim does each time you hit the "%" key.  If
+there are |backref|s in |b:match_words| then the first step is to produce a
+version in which these back references have been eliminated; if there are no
+|backref|s then this step is skipped.  This step is called parsing.  For
+example, "\(foo\|bar\):end\1" is parsed to yield
+"\(foo\|bar\):end\(foo\|bar\)".  This can get tricky, especially if there are
+nested groups.  If debugging is turned on, the parsed version is saved as
+|b:match_pat|.
+
+                                                       *matchit-choose*
+Next, the script looks for a word on the current line that matches the pattern
+just constructed.  It includes the patterns from the 'matchpairs' option.
+The goal is to do what you expect, which turns out to be a little complicated.
+The script follows these rules:
+
+       Insist on a match that ends on or after the cursor.
+       Prefer a match that includes the cursor position (that is, one that
+               starts on or before the cursor).
+       Prefer a match that starts as close to the cursor as possible.
+       If more than one pattern in |b:match_words| matches, choose the one
+               that is listed first.
+
+Examples:
+
+       Suppose you >
+               :let b:match_words = '<:>,<tag>:</tag>'
+<      and hit "%" with the cursor on or before the "<" in "a <tag> is born".
+       The pattern '<' comes first, so it is preferred over '<tag>', which
+       also matches.  If the cursor is on the "t", however, then '<tag>' is
+       preferred, because this matches a bit of text containing the cursor.
+       If the two groups of patterns were reversed then '<' would never be
+       preferred.
+
+       Suppose you >
+               :let b:match_words = 'if:end if'
+<      (Note the space!) and hit "%" with the cursor at the end of "end if".
+       Then "if" matches, which is probably not what you want, but if the
+       cursor starts on the "end " then "end if" is chosen.  (You can avoid
+       this problem by using a more complicated pattern.)
+
+If there is no match, the cursor does not move.  (Before version 1.13 of the
+script, it would fall back on the usual behavior of |%|).  If debugging is
+turned on, the matched bit of text is saved as |b:match_match| and the cursor
+column of the start of the match is saved as |b:match_col|.
+
+Next, the script looks through |b:match_words| (original and parsed versions)
+for the group and pattern that match.  If debugging is turned on, the group is
+saved as |b:match_ini| (the first pattern) and |b:match_tail| (the rest).  If
+there are |backref|s then, in addition, the matching pattern is saved as
+|b:match_word| and a table of translations is saved as |b:match_table|.  If
+there are |backref|s, these are determined from the matching pattern and
+|b:match_match| and substituted into each pattern in the matching group.
+
+The script decides whether to search forwards or backwards and chooses
+arguments for the |searchpair()| function.  Then, the cursor is moved to the
+start of the match, and |searchpair()| is called.  By default, matching
+structures inside strings and comments are ignored.  This can be changed by
+setting |b:match_skip|.
+
+==============================================================================
+2. Activation                                          *matchit-activate*
+
+You can use this script as a plugin, by copying it to your plugin directory.
+See |add-global-plugin| for instructions.  You can also add a line to your
+|vimrc| file, such as >
+       :source $VIMRUNTIME/macros/matchit.vim
+or >
+       :runtime macros/matchit.vim
+Either way, the script should start working the next time you start up Vim.
+
+(Earlier versions of the script did nothing unless a |buffer-variable| named
+|b:match_words| was defined.  Even earlier versions contained autocommands
+that set this variable for various file types.  Now, |b:match_words| is
+defined in many of the default |filetype-plugin|s instead.)
+
+For a new language, you can add autocommands to the script or to your vimrc
+file, but the recommended method is to add a line such as >
+       let b:match_words = '\<foo\>:\<bar\>'
+to the |filetype-plugin| for your language.  See |b:match_words| below for how
+this variable is interpreted.
+
+TROUBLESHOOTING                                        *matchit-troubleshoot*
+
+The script should work in most installations of Vim.  It may not work if Vim
+was compiled with a minimal feature set, for example if the |+syntax| option
+was not enabled.  If your Vim has support for syntax compiled in, but you do
+not have |syntax| highlighting turned on, matchit.vim should work, but it may
+fail to skip matching groups in comments and strings.  If the |filetype|
+mechanism is turned off, the |b:match_words| variable will probably not be
+defined automatically.
+
+==============================================================================
+3. Configuration                                       *matchit-configure*
+
+There are several variables that govern the behavior of matchit.vim.  Note
+that these are variables local to the buffer, not options, so use |:let| to
+define them, not |:set|.  Some of these variables have values that matter; for
+others, it only matters whether the variable has been defined.  All of these
+can be defined in the |filetype-plugin| or autocommand that defines
+|b:match_words| or "on the fly."
+
+The main variable is |b:match_words|.  It is described in the section below on
+supporting a new language.
+
+                               *MatchError* *matchit-hl* *matchit-highlight*
+MatchError is the highlight group for error messages from the script.  By
+default, it is linked to WarningMsg.  If you do not want to be bothered by
+error messages, you can define this to be something invisible.  For example,
+if you use the GUI version of Vim and your command line is normally white, you
+can do >
+       :hi MatchError guifg=white guibg=white
+<
+                                               *b:match_ignorecase*
+If you >
+       :let b:match_ignorecase = 1
+then matchit.vim acts as if 'ignorecase' is set: for example, "end" and "END"
+are equivalent.  If you >
+       :let b:match_ignorecase = 0
+then matchit.vim treats "end" and "END" differently.  (There will be no
+b:match_infercase option unless someone requests it.)
+
+                                               *b:match_debug*
+Define b:match_debug if you want debugging information to be saved.  See
+|matchit-debug|, below.
+
+                                               *b:match_skip*
+If b:match_skip is defined, it is passed as the skip argument to
+|searchpair()|.  This controls when matching structures are skipped, or
+ignored.  By default, they are ignored inside comments and strings, as
+determined by the |syntax| mechanism.  (If syntax highlighting is turned off,
+nothing is skipped.)  You can set b:match_skip to a string, which evaluates to
+a non-zero, numerical value if the match is to be skipped or zero if the match
+should not be skipped.  In addition, the following special values are
+supported by matchit.vim:
+       s:foo becomes (current syntax item) =~ foo
+       S:foo becomes (current syntax item) !~ foo
+       r:foo becomes (line before cursor) =~ foo
+       R:foo becomes (line before cursor) !~ foo
+(The "s" is meant to suggest "syntax", and the "r" is meant to suggest
+"regular expression".)
+
+Examples:
+
+       You can get the default behavior with >
+               :let b:match_skip = 's:comment\|string'
+<
+       If you want to skip matching structures unless they are at the start
+       of the line (ignoring whitespace) then you can >
+               :let b:match_skip = 'R:^\s*'
+<      Do not do this if strings or comments can span several lines, since
+       the normal syntax checking will not be done if you set b:match_skip.
+
+       In LaTeX, since "%" is used as the comment character, you can >
+               :let b:match_skip = 'r:%'
+<      Unfortunately, this will skip anything after "\%", an escaped "%".  To
+       allow for this, and also "\\%" (an excaped backslash followed by the
+       comment character) you can >
+               :let b:match_skip = 'r:\(^\|[^\\]\)\(\\\\\)*%'
+<
+       See the $VIMRUNTIME/ftplugin/vim.vim for an example that uses both
+       syntax and a regular expression.
+
+==============================================================================
+4. Supporting a New Language                           *matchit-newlang*
+                                                       *b:match_words*
+In order for matchit.vim to support a new language, you must define a suitable
+pattern for |b:match_words|.  You may also want to set some of the
+|matchit-configure| variables, as described above.  If your language has a
+complicated syntax, or many keywords, you will need to know something about
+Vim's |regular-expression|s.
+
+The format for |b:match_words| is similar to that of the 'matchpairs' option:
+it is a comma (,)-separated list of groups; each group is a colon(:)-separated
+list of patterns (regular expressions).  Commas and backslashes that are part
+of a pattern should be escaped with backslashes ('\:' and '\,').  It is OK to
+have only one group; the effect is undefined if a group has only one pattern.
+A simple example is >
+       :let b:match_words = '\<if\>:\<endif\>,'
+               \ . '\<while\>:\<continue\>:\<break\>:\<endwhile\>'
+(In Vim regular expressions, |\<| and |\>| denote word boundaries.  Thus "if"
+matches the end of "endif" but "\<if\>" does not.)  Then banging on the "%"
+key will bounce the cursor between "if" and the matching "endif"; and from
+"while" to any matching "continue" or "break", then to the matching "endwhile"
+and back to the "while".  It is almost always easier to use |literal-string|s
+(single quotes) as above:  '\<if\>' rather than "\\<if\\>" and so on.
+
+Exception:  If the ":" character does not appear in b:match_words, then it is
+treated as an expression to be evaluated.  For example, >
+       :let b:match_words = 'GetMatchWords()'
+allows you to define a function.  This can return a different string depending
+on the current syntax, for example.
+
+Once you have defined the appropriate value of |b:match_words|, you will
+probably want to have this set automatically each time you edit the
+appropriate file type.  The recommended way to do this is by adding the
+definition to a |filetype-plugin| file.
+
+Tips: Be careful that your initial pattern does not match your final pattern.
+See the example above for the use of word-boundary expressions.  It is usually
+better to use ".\{-}" (as many as necessary) instead of ".*" (as many as
+possible).  See |\{-|.  For example, in the string "<tag>label</tag>", "<.*>"
+matches the whole string whereas "<.\{-}>" and "<[^>]*>" match "<tag>" and
+"</tag>".
+
+                               *matchit-spaces* *matchit-s:notend*
+If "if" is to be paired with "end if" (Note the space!) then word boundaries
+are not enough.  Instead, define a regular expression s:notend that will match
+anything but "end" and use it as follows: >
+       :let s:notend = '\%(\<end\s\+\)\@<!'
+       :let b:match_words = s:notend . '\<if\>:\<end\s\+if\>'
+<                                                      *matchit-s:sol*
+This is a simplified version of what is done for Ada.  The s:notend is a
+|script-variable|.  Similarly, you may want to define a start-of-line regular
+expression >
+       :let s:sol = '\%(^\|;\)\s*'
+if keywords are only recognized after the start of a line or after a
+semicolon (;), with optional white space.
+
+                                       *matchit-backref* *matchit-\1*
+In any group, the expressions |\1|, |\2|, ..., |\9| refer to parts of the
+INITIAL pattern enclosed in |\(|escaped parentheses|\)|.  These are referred
+to as back references, or backrefs.  For example, >
+       :let b:match_words = '\<b\(o\+\)\>:\(h\)\1\>'
+means that "bo" pairs with "ho" and "boo" pairs with "hoo" and so on.  Note
+that "\1" does not refer to the "\(h\)" in this example.  If you have
+"\(nested \(parentheses\)\) then "\d" refers to the d-th "\(" and everything
+up to and including the matching "\)":  in "\(nested\(parentheses\)\)", "\1"
+refers to everything and "\2" refers to "\(parentheses\)".  If you use a
+variable such as |s:notend| or |s:sol| in the previous paragraph then remember
+to count any "\(" patterns in this variable.  You do not have to count groups
+defined by |\%(\)|.
+
+It should be possible to resolve back references from any pattern in the
+group.  For example, >
+       :let b:match_words = '\(foo\)\(bar\):more\1:and\2:end\1\2'
+would not work because "\2" cannot be determined from "morefoo" and "\1"
+cannot be determined from "andbar".  On the other hand, >
+       :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1'
+should work (and have the same effect as "foobar:barfoo:endfoobar"), although
+this has not been thoroughly tested.
+
+You can use |zero-width| patterns such as |\@<=| and |\zs|.  (The latter has
+not been thouroughly tested in matchit.vim.)  For example, if the keyword "if"
+must occur at the start of the line, with optional white space, you might use
+the pattern "\(^\s*\)\@<=if" so that the cursor will end on the "i" instead of
+at the start of the line.  For another example, if HTML had only one tag then
+one could >
+       :let b:match_words = '<:>,<\@<=tag>:<\@<=/tag>'
+so that "%" can bounce between matching "<" and ">" pairs or (starting on
+"tag" or "/tag") between matching tags.  Without the |\@<=|, the script would
+bounce from "tag" to the "<" in "</tag>", and another "%" would not take you
+back to where you started.
+
+DEBUGGING                              *matchit-debug* *:MatchDebug*
+
+If you are having trouble figuring out the appropriate definition of
+|b:match_words| then you can take advantage of the same information I use when
+debugging the script.  This is especially true if you are not sure whether
+your patterns or my script are at fault!  To make this more convenient, I have
+made the command :MatchDebug, which defines the variable |b:match_debug| and
+creates a Matchit menu.  This menu makes it convenient to check the values of
+the variables described below.  You will probably also want to read
+|matchit-details| above.
+
+Defining the variable |b:match_debug| causes the script to set the following
+variables, each time you hit the "%" key.  Several of these are only defined
+if |b:match_words| includes |backref|s.
+
+                                                       *b:match_pat*
+The b:match_pat variable is set to |b:match_words| with |backref|s parsed.
+                                                       *b:match_match*
+The b:match_match variable is set to the bit of text that is recognized as a
+match.
+                                                       *b:match_col*
+The b:match_col variable is set to the cursor column of the start of the
+matching text.
+                                                       *b:match_wholeBR*
+The b:match_wholeBR variable is set to the comma-separated group of patterns
+that matches, with |backref|s unparsed.
+                                                       *b:match_iniBR*
+The b:match_iniBR variable is set to the first pattern in |b:match_wholeBR|.
+                                                       *b:match_ini*
+The b:match_ini variable is set to the first pattern in |b:match_wholeBR|,
+with |backref|s resolved from |b:match_match|.
+                                                       *b:match_tail*
+The b:match_tail variable is set to the remaining patterns in
+|b:match_wholeBR|, with |backref|s resolved from |b:match_match|.
+                                                       *b:match_word*
+The b:match_word variable is set to the pattern from |b:match_wholeBR| that
+matches |b:match_match|.
+                                                       *b:match_table*
+The back reference '\'.d refers to the same thing as '\'.b:match_table[d] in
+|b:match_word|.
+
+==============================================================================
+5. Known Bugs and Limitations                          *matchit-bugs*
+
+Just because I know about a bug does not mean that it is on my todo list.  I
+try to respond to reports of bugs that cause real problems.  If it does not
+cause serious problems, or if there is a work-around, a bug may sit there for
+a while.  Moral:  if a bug (known or not) bothers you, let me know.
+
+The various |:vmap|s defined in the script (%, |g%|, |[%|, |]%|, |a%|) may
+have undesired effects in Select mode |Select-mode-mapping|.  At least, if you
+want to replace the selection with any character in "ag%[]" there will be a
+pause of |'updatetime'| first.
+
+It would be nice if "\0" were recognized as the entire pattern.  That is, it
+would be nice if "foo:\end\0" had the same effect as "\(foo\):\end\1".  I may
+try to implement this in a future version.  (This is not so easy to arrange as
+you might think!)
+
+==============================================================================
+vim:tw=78:fo=tcq2:
diff --git a/vim/vim/bundle/matchit/plugin/matchit.vim b/vim/vim/bundle/matchit/plugin/matchit.vim
new file mode 100644 (file)
index 0000000..e41cda9
--- /dev/null
@@ -0,0 +1,812 @@
+"  matchit.vim: (global plugin) Extended "%" matching
+"  Last Change: Fri Jan 25 10:00 AM 2008 EST
+"  Maintainer:  Benji Fisher PhD   <benji@member.AMS.org>
+"  Version:     1.13.2, for Vim 6.3+
+"  URL:                http://www.vim.org/script.php?script_id=39
+
+" Documentation:
+"  The documentation is in a separate file, matchit.txt .
+
+" Credits:
+"  Vim editor by Bram Moolenaar (Thanks, Bram!)
+"  Original script and design by Raul Segura Acevedo
+"  Support for comments by Douglas Potts
+"  Support for back references and other improvements by Benji Fisher
+"  Support for many languages by Johannes Zellner
+"  Suggestions for improvement, bug reports, and support for additional
+"  languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark
+"  Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner.
+
+" Debugging:
+"  If you'd like to try the built-in debugging commands...
+"   :MatchDebug      to activate debugging for the current buffer
+"  This saves the values of several key script variables as buffer-local
+"  variables.  See the MatchDebug() function, below, for details.
+
+" TODO:  I should think about multi-line patterns for b:match_words.
+"   This would require an option:  how many lines to scan (default 1).
+"   This would be useful for Python, maybe also for *ML.
+" TODO:  Maybe I should add a menu so that people will actually use some of
+"   the features that I have implemented.
+" TODO:  Eliminate the MultiMatch function.  Add yet another argument to
+"   Match_wrapper() instead.
+" TODO:  Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1'
+" TODO:  Make backrefs safer by using '\V' (very no-magic).
+" TODO:  Add a level of indirection, so that custom % scripts can use my
+"   work but extend it.
+
+" allow user to prevent loading
+" and prevent duplicate loading
+if exists("loaded_matchit") || &cp
+  finish
+endif
+let loaded_matchit = 1
+let s:last_mps = ""
+let s:last_words = ":"
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+nnoremap <silent> %  :<C-U>call <SID>Match_wrapper('',1,'n') <CR>
+nnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'n') <CR>
+vnoremap <silent> %  :<C-U>call <SID>Match_wrapper('',1,'v') <CR>m'gv``
+vnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'v') <CR>m'gv``
+onoremap <silent> %  v:<C-U>call <SID>Match_wrapper('',1,'o') <CR>
+onoremap <silent> g% v:<C-U>call <SID>Match_wrapper('',0,'o') <CR>
+
+" Analogues of [{ and ]} using matching patterns:
+nnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "n") <CR>
+nnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W",  "n") <CR>
+vmap [% <Esc>[%m'gv``
+vmap ]% <Esc>]%m'gv``
+" vnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "v") <CR>m'gv``
+" vnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W",  "v") <CR>m'gv``
+onoremap <silent> [% v:<C-U>call <SID>MultiMatch("bW", "o") <CR>
+onoremap <silent> ]% v:<C-U>call <SID>MultiMatch("W",  "o") <CR>
+
+" text object:
+vmap a% <Esc>[%v]%
+
+" Auto-complete mappings:  (not yet "ready for prime time")
+" TODO Read :help write-plugin for the "right" way to let the user
+" specify a key binding.
+"   let g:match_auto = '<C-]>'
+"   let g:match_autoCR = '<C-CR>'
+" if exists("g:match_auto")
+"   execute "inoremap " . g:match_auto . ' x<Esc>"=<SID>Autocomplete()<CR>Pls'
+" endif
+" if exists("g:match_autoCR")
+"   execute "inoremap " . g:match_autoCR . ' <CR><C-R>=<SID>Autocomplete()<CR>'
+" endif
+" if exists("g:match_gthhoh")
+"   execute "inoremap " . g:match_gthhoh . ' <C-O>:call <SID>Gthhoh()<CR>'
+" endif " gthhoh = "Get the heck out of here!"
+
+let s:notslash = '\\\@<!\%(\\\\\)*'
+
+function! s:Match_wrapper(word, forward, mode) range
+  " In s:CleanUp(), :execute "set" restore_options .
+  let restore_options = (&ic ? " " : " no") . "ignorecase"
+  if exists("b:match_ignorecase")
+    let &ignorecase = b:match_ignorecase
+  endif
+  let restore_options = " ve=" . &ve . restore_options
+  set ve=
+  " If this function was called from Visual mode, make sure that the cursor
+  " is at the correct end of the Visual range:
+  if a:mode == "v"
+    execute "normal! gv\<Esc>"
+  endif
+  " In s:CleanUp(), we may need to check whether the cursor moved forward.
+  let startline = line(".")
+  let startcol = col(".")
+  " Use default behavior if called with a count.
+  if v:count
+    exe "normal! " . v:count . "%"
+    return s:CleanUp(restore_options, a:mode, startline, startcol)
+  end
+
+  " First step:  if not already done, set the script variables
+  "   s:do_BR  flag for whether there are backrefs
+  "   s:pat    parsed version of b:match_words
+  "   s:all    regexp based on s:pat and the default groups
+  "
+  if !exists("b:match_words") || b:match_words == ""
+    let match_words = ""
+    " Allow b:match_words = "GetVimMatchWords()" .
+  elseif b:match_words =~ ":"
+    let match_words = b:match_words
+  else
+    execute "let match_words =" b:match_words
+  endif
+" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion!
+  if (match_words != s:last_words) || (&mps != s:last_mps) ||
+    \ exists("b:match_debug")
+    let s:last_words = match_words
+    let s:last_mps = &mps
+    " The next several lines were here before
+    " BF started messing with this script.
+    " quote the special chars in 'matchpairs', replace [,:] with \| and then
+    " append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif)
+    " let default = substitute(escape(&mps, '[$^.*~\\/?]'), '[,:]\+',
+    "  \ '\\|', 'g').'\|\/\*\|\*\/\|#if\>\|#ifdef\>\|#else\>\|#elif\>\|#endif\>'
+    let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
+      \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>'
+    " s:all = pattern with all the keywords
+    let match_words = match_words . (strlen(match_words) ? "," : "") . default
+    if match_words !~ s:notslash . '\\\d'
+      let s:do_BR = 0
+      let s:pat = match_words
+    else
+      let s:do_BR = 1
+      let s:pat = s:ParseWords(match_words)
+    endif
+    let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g')
+    let s:all = '\%(' . s:all . '\)'
+    " let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)'
+    if exists("b:match_debug")
+      let b:match_pat = s:pat
+    endif
+  endif
+
+  " Second step:  set the following local variables:
+  "     matchline = line on which the cursor started
+  "     curcol    = number of characters before match
+  "     prefix    = regexp for start of line to start of match
+  "     suffix    = regexp for end of match to end of line
+  " Require match to end on or after the cursor and prefer it to
+  " start on or before the cursor.
+  let matchline = getline(startline)
+  if a:word != ''
+    " word given
+    if a:word !~ s:all
+      echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE
+      return s:CleanUp(restore_options, a:mode, startline, startcol)
+    endif
+    let matchline = a:word
+    let curcol = 0
+    let prefix = '^\%('
+    let suffix = '\)$'
+  " Now the case when "word" is not given
+  else " Find the match that ends on or after the cursor and set curcol.
+    let regexp = s:Wholematch(matchline, s:all, startcol-1)
+    let curcol = match(matchline, regexp)
+    " If there is no match, give up.
+    if curcol == -1
+      return s:CleanUp(restore_options, a:mode, startline, startcol)
+    endif
+    let endcol = matchend(matchline, regexp)
+    let suf = strlen(matchline) - endcol
+    let prefix = (curcol ? '^.*\%'  . (curcol + 1) . 'c\%(' : '^\%(')
+    let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$'  : '\)$')
+  endif
+  if exists("b:match_debug")
+    let b:match_match = matchstr(matchline, regexp)
+    let b:match_col = curcol+1
+  endif
+
+  " Third step:  Find the group and single word that match, and the original
+  " (backref) versions of these.  Then, resolve the backrefs.
+  " Set the following local variable:
+  " group = colon-separated list of patterns, one of which matches
+  "       = ini:mid:fin or ini:fin
+  "
+  " Reconstruct the version with unresolved backrefs.
+  let patBR = substitute(match_words.',',
+    \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
+  let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g')
+  " Now, set group and groupBR to the matching group: 'if:endif' or
+  " 'while:endwhile' or whatever.  A bit of a kluge:  s:Choose() returns
+  " group . "," . groupBR, and we pick it apart.
+  let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR)
+  let i = matchend(group, s:notslash . ",")
+  let groupBR = strpart(group, i)
+  let group = strpart(group, 0, i-1)
+  " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
+  if s:do_BR " Do the hard part:  resolve those backrefs!
+    let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
+  endif
+  if exists("b:match_debug")
+    let b:match_wholeBR = groupBR
+    let i = matchend(groupBR, s:notslash . ":")
+    let b:match_iniBR = strpart(groupBR, 0, i-1)
+  endif
+
+  " Fourth step:  Set the arguments for searchpair().
+  let i = matchend(group, s:notslash . ":")
+  let j = matchend(group, '.*' . s:notslash . ":")
+  let ini = strpart(group, 0, i-1)
+  let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g')
+  let fin = strpart(group, j)
+  "Un-escape the remaining , and : characters.
+  let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
+  let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
+  let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
+  " searchpair() requires that these patterns avoid \(\) groups.
+  let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g')
+  let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g')
+  let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g')
+  " Set mid.  This is optimized for readability, not micro-efficiency!
+  if a:forward && matchline =~ prefix . fin . suffix
+    \ || !a:forward && matchline =~ prefix . ini . suffix
+    let mid = ""
+  endif
+  " Set flag.  This is optimized for readability, not micro-efficiency!
+  if a:forward && matchline =~ prefix . fin . suffix
+    \ || !a:forward && matchline !~ prefix . ini . suffix
+    let flag = "bW"
+  else
+    let flag = "W"
+  endif
+  " Set skip.
+  if exists("b:match_skip")
+    let skip = b:match_skip
+  elseif exists("b:match_comment") " backwards compatibility and testing!
+    let skip = "r:" . b:match_comment
+  else
+    let skip = 's:comment\|string'
+  endif
+  let skip = s:ParseSkip(skip)
+  if exists("b:match_debug")
+    let b:match_ini = ini
+    let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin
+  endif
+
+  " Fifth step:  actually start moving the cursor and call searchpair().
+  " Later, :execute restore_cursor to get to the original screen.
+  let restore_cursor = virtcol(".") . "|"
+  normal! g0
+  let restore_cursor = line(".") . "G" .  virtcol(".") . "|zs" . restore_cursor
+  normal! H
+  let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
+  execute restore_cursor
+  call cursor(0, curcol + 1)
+  " normal! 0
+  " if curcol
+  "   execute "normal!" . curcol . "l"
+  " endif
+  if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
+    let skip = "0"
+  else
+    execute "if " . skip . "| let skip = '0' | endif"
+  endif
+  let sp_return = searchpair(ini, mid, fin, flag, skip)
+  let final_position = "call cursor(" . line(".") . "," . col(".") . ")"
+  " Restore cursor position and original screen.
+  execute restore_cursor
+  normal! m'
+  if sp_return > 0
+    execute final_position
+  endif
+  return s:CleanUp(restore_options, a:mode, startline, startcol, mid.'\|'.fin)
+endfun
+
+" Restore options and do some special handling for Operator-pending mode.
+" The optional argument is the tail of the matching group.
+fun! s:CleanUp(options, mode, startline, startcol, ...)
+  execute "set" a:options
+  " Open folds, if appropriate.
+  if a:mode != "o"
+    if &foldopen =~ "percent"
+      normal! zv
+    endif
+    " In Operator-pending mode, we want to include the whole match
+    " (for example, d%).
+    " This is only a problem if we end up moving in the forward direction.
+  elseif (a:startline < line(".")) ||
+       \ (a:startline == line(".") && a:startcol < col("."))
+    if a:0
+      " Check whether the match is a single character.  If not, move to the
+      " end of the match.
+      let matchline = getline(".")
+      let currcol = col(".")
+      let regexp = s:Wholematch(matchline, a:1, currcol-1)
+      let endcol = matchend(matchline, regexp)
+      if endcol > currcol  " This is NOT off by one!
+       execute "normal!" . (endcol - currcol) . "l"
+      endif
+    endif " a:0
+  endif " a:mode != "o" && etc.
+  return 0
+endfun
+
+" Example (simplified HTML patterns):  if
+"   a:groupBR  = '<\(\k\+\)>:</\1>'
+"   a:prefix   = '^.\{3}\('
+"   a:group    = '<\(\k\+\)>:</\(\k\+\)>'
+"   a:suffix   = '\).\{2}$'
+"   a:matchline        =  "123<tag>12" or "123</tag>12"
+" then extract "tag" from a:matchline and return "<tag>:</tag>" .
+fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline)
+  if a:matchline !~ a:prefix .
+    \ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix
+    return a:group
+  endif
+  let i = matchend(a:groupBR, s:notslash . ':')
+  let ini = strpart(a:groupBR, 0, i-1)
+  let tailBR = strpart(a:groupBR, i)
+  let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix,
+    \ a:groupBR)
+  let i = matchend(word, s:notslash . ":")
+  let wordBR = strpart(word, i)
+  let word = strpart(word, 0, i-1)
+  " Now, a:matchline =~ a:prefix . word . a:suffix
+  if wordBR != ini
+    let table = s:Resolve(ini, wordBR, "table")
+  else
+    " let table = "----------"
+    let table = ""
+    let d = 0
+    while d < 10
+      if tailBR =~ s:notslash . '\\' . d
+       " let table[d] = d
+       let table = table . d
+      else
+       let table = table . "-"
+      endif
+      let d = d + 1
+    endwhile
+  endif
+  let d = 9
+  while d
+    if table[d] != "-"
+      let backref = substitute(a:matchline, a:prefix.word.a:suffix,
+       \ '\'.table[d], "")
+       " Are there any other characters that should be escaped?
+      let backref = escape(backref, '*,:')
+      execute s:Ref(ini, d, "start", "len")
+      let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len)
+      let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d,
+       \ escape(backref, '\\'), 'g')
+    endif
+    let d = d-1
+  endwhile
+  if exists("b:match_debug")
+    if s:do_BR
+      let b:match_table = table
+      let b:match_word = word
+    else
+      let b:match_table = ""
+      let b:match_word = ""
+    endif
+  endif
+  return ini . ":" . tailBR
+endfun
+
+" Input a comma-separated list of groups with backrefs, such as
+"   a:groups = '\(foo\):end\1,\(bar\):end\1'
+" and return a comma-separated list of groups with backrefs replaced:
+"   return '\(foo\):end\(foo\),\(bar\):end\(bar\)'
+fun! s:ParseWords(groups)
+  let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
+  let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g')
+  let parsed = ""
+  while groups =~ '[^,:]'
+    let i = matchend(groups, s:notslash . ':')
+    let j = matchend(groups, s:notslash . ',')
+    let ini = strpart(groups, 0, i-1)
+    let tail = strpart(groups, i, j-i-1) . ":"
+    let groups = strpart(groups, j)
+    let parsed = parsed . ini
+    let i = matchend(tail, s:notslash . ':')
+    while i != -1
+      " In 'if:else:endif', ini='if' and word='else' and then word='endif'.
+      let word = strpart(tail, 0, i-1)
+      let tail = strpart(tail, i)
+      let i = matchend(tail, s:notslash . ':')
+      let parsed = parsed . ":" . s:Resolve(ini, word, "word")
+    endwhile " Now, tail has been used up.
+    let parsed = parsed . ","
+  endwhile " groups =~ '[^,:]'
+  let parsed = substitute(parsed, ',$', '', '')
+  return parsed
+endfun
+
+" TODO I think this can be simplified and/or made more efficient.
+" TODO What should I do if a:start is out of range?
+" Return a regexp that matches all of a:string, such that
+" matchstr(a:string, regexp) represents the match for a:pat that starts
+" as close to a:start as possible, before being preferred to after, and
+" ends after a:start .
+" Usage:
+" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1)
+" let i      = match(getline("."), regexp)
+" let j      = matchend(getline("."), regexp)
+" let match  = matchstr(getline("."), regexp)
+fun! s:Wholematch(string, pat, start)
+  let group = '\%(' . a:pat . '\)'
+  let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^')
+  let len = strlen(a:string)
+  let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$')
+  if a:string !~ prefix . group . suffix
+    let prefix = ''
+  endif
+  return prefix . group . suffix
+endfun
+
+" No extra arguments:  s:Ref(string, d) will
+" find the d'th occurrence of '\(' and return it, along with everything up
+" to and including the matching '\)'.
+" One argument:  s:Ref(string, d, "start") returns the index of the start
+" of the d'th '\(' and any other argument returns the length of the group.
+" Two arguments:  s:Ref(string, d, "foo", "bar") returns a string to be
+" executed, having the effect of
+"   :let foo = s:Ref(string, d, "start")
+"   :let bar = s:Ref(string, d, "len")
+fun! s:Ref(string, d, ...)
+  let len = strlen(a:string)
+  if a:d == 0
+    let start = 0
+  else
+    let cnt = a:d
+    let match = a:string
+    while cnt
+      let cnt = cnt - 1
+      let index = matchend(match, s:notslash . '\\(')
+      if index == -1
+       return ""
+      endif
+      let match = strpart(match, index)
+    endwhile
+    let start = len - strlen(match)
+    if a:0 == 1 && a:1 == "start"
+      return start - 2
+    endif
+    let cnt = 1
+    while cnt
+      let index = matchend(match, s:notslash . '\\(\|\\)') - 1
+      if index == -2
+       return ""
+      endif
+      " Increment if an open, decrement if a ')':
+      let cnt = cnt + (match[index]=="(" ? 1 : -1)  " ')'
+      " let cnt = stridx('0(', match[index]) + cnt
+      let match = strpart(match, index+1)
+    endwhile
+    let start = start - 2
+    let len = len - start - strlen(match)
+  endif
+  if a:0 == 1
+    return len
+  elseif a:0 == 2
+    return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len
+  else
+    return strpart(a:string, start, len)
+  endif
+endfun
+
+" Count the number of disjoint copies of pattern in string.
+" If the pattern is a literal string and contains no '0' or '1' characters
+" then s:Count(string, pattern, '0', '1') should be faster than
+" s:Count(string, pattern).
+fun! s:Count(string, pattern, ...)
+  let pat = escape(a:pattern, '\\')
+  if a:0 > 1
+    let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g")
+    let foo = substitute(a:string, pat, a:2, "g")
+    let foo = substitute(foo, '[^' . a:2 . ']', "", "g")
+    return strlen(foo)
+  endif
+  let result = 0
+  let foo = a:string
+  let index = matchend(foo, pat)
+  while index != -1
+    let result = result + 1
+    let foo = strpart(foo, index)
+    let index = matchend(foo, pat)
+  endwhile
+  return result
+endfun
+
+" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where
+" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'.  That is, the first
+" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this
+" indicates that all other instances of '\1' in target are to be replaced
+" by '\3'.  The hard part is dealing with nesting...
+" Note that ":" is an illegal character for source and target,
+" unless it is preceded by "\".
+fun! s:Resolve(source, target, output)
+  let word = a:target
+  let i = matchend(word, s:notslash . '\\\d') - 1
+  let table = "----------"
+  while i != -2 " There are back references to be replaced.
+    let d = word[i]
+    let backref = s:Ref(a:source, d)
+    " The idea is to replace '\d' with backref.  Before we do this,
+    " replace any \(\) groups in backref with :1, :2, ... if they
+    " correspond to the first, second, ... group already inserted
+    " into backref.  Later, replace :1 with \1 and so on.  The group
+    " number w+b within backref corresponds to the group number
+    " s within a:source.
+    " w = number of '\(' in word before the current one
+    let w = s:Count(
+    \ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1')
+    let b = 1 " number of the current '\(' in backref
+    let s = d " number of the current '\(' in a:source
+    while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1')
+    \ && s < 10
+      if table[s] == "-"
+       if w + b < 10
+         " let table[s] = w + b
+         let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1)
+       endif
+       let b = b + 1
+       let s = s + 1
+      else
+       execute s:Ref(backref, b, "start", "len")
+       let ref = strpart(backref, start, len)
+       let backref = strpart(backref, 0, start) . ":". table[s]
+       \ . strpart(backref, start+len)
+       let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1')
+      endif
+    endwhile
+    let word = strpart(word, 0, i-1) . backref . strpart(word, i+1)
+    let i = matchend(word, s:notslash . '\\\d') - 1
+  endwhile
+  let word = substitute(word, s:notslash . '\zs:', '\\', 'g')
+  if a:output == "table"
+    return table
+  elseif a:output == "word"
+    return word
+  else
+    return table . word
+  endif
+endfun
+
+" Assume a:comma = ",".  Then the format for a:patterns and a:1 is
+"   a:patterns = "<pat1>,<pat2>,..."
+"   a:1 = "<alt1>,<alt2>,..."
+" If <patn> is the first pattern that matches a:string then return <patn>
+" if no optional arguments are given; return <patn>,<altn> if a:1 is given.
+fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...)
+  let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma)
+  let i = matchend(tail, s:notslash . a:comma)
+  if a:0
+    let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma)
+    let j = matchend(alttail, s:notslash . a:comma)
+  endif
+  let current = strpart(tail, 0, i-1)
+  if a:branch == ""
+    let currpat = current
+  else
+    let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
+  endif
+  while a:string !~ a:prefix . currpat . a:suffix
+    let tail = strpart(tail, i)
+    let i = matchend(tail, s:notslash . a:comma)
+    if i == -1
+      return -1
+    endif
+    let current = strpart(tail, 0, i-1)
+    if a:branch == ""
+      let currpat = current
+    else
+      let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
+    endif
+    if a:0
+      let alttail = strpart(alttail, j)
+      let j = matchend(alttail, s:notslash . a:comma)
+    endif
+  endwhile
+  if a:0
+    let current = current . a:comma . strpart(alttail, 0, j-1)
+  endif
+  return current
+endfun
+
+" Call this function to turn on debugging information.  Every time the main
+" script is run, buffer variables will be saved.  These can be used directly
+" or viewed using the menu items below.
+if !exists(":MatchDebug")
+  command! -nargs=0 MatchDebug call s:Match_debug()
+endif
+
+fun! s:Match_debug()
+  let b:match_debug = 1        " Save debugging information.
+  " pat = all of b:match_words with backrefs parsed
+  amenu &Matchit.&pat  :echo b:match_pat<CR>
+  " match = bit of text that is recognized as a match
+  amenu &Matchit.&match        :echo b:match_match<CR>
+  " curcol = cursor column of the start of the matching text
+  amenu &Matchit.&curcol       :echo b:match_col<CR>
+  " wholeBR = matching group, original version
+  amenu &Matchit.wh&oleBR      :echo b:match_wholeBR<CR>
+  " iniBR = 'if' piece, original version
+  amenu &Matchit.ini&BR        :echo b:match_iniBR<CR>
+  " ini = 'if' piece, with all backrefs resolved from match
+  amenu &Matchit.&ini  :echo b:match_ini<CR>
+  " tail = 'else\|endif' piece, with all backrefs resolved from match
+  amenu &Matchit.&tail :echo b:match_tail<CR>
+  " fin = 'endif' piece, with all backrefs resolved from match
+  amenu &Matchit.&word :echo b:match_word<CR>
+  " '\'.d in ini refers to the same thing as '\'.table[d] in word.
+  amenu &Matchit.t&able        :echo '0:' . b:match_table . ':9'<CR>
+endfun
+
+" Jump to the nearest unmatched "(" or "if" or "<tag>" if a:spflag == "bW"
+" or the nearest unmatched "</tag>" or "endif" or ")" if a:spflag == "W".
+" Return a "mark" for the original position, so that
+"   let m = MultiMatch("bW", "n") ... execute m
+" will return to the original position.  If there is a problem, do not
+" move the cursor and return "", unless a count is given, in which case
+" go up or down as many levels as possible and again return "".
+" TODO This relies on the same patterns as % matching.  It might be a good
+" idea to give it its own matching patterns.
+fun! s:MultiMatch(spflag, mode)
+  if !exists("b:match_words") || b:match_words == ""
+    return ""
+  end
+  let restore_options = (&ic ? "" : "no") . "ignorecase"
+  if exists("b:match_ignorecase")
+    let &ignorecase = b:match_ignorecase
+  endif
+  let startline = line(".")
+  let startcol = col(".")
+
+  " First step:  if not already done, set the script variables
+  "   s:do_BR  flag for whether there are backrefs
+  "   s:pat    parsed version of b:match_words
+  "   s:all    regexp based on s:pat and the default groups
+  " This part is copied and slightly modified from s:Match_wrapper().
+  let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
+    \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>'
+  " Allow b:match_words = "GetVimMatchWords()" .
+  if b:match_words =~ ":"
+    let match_words = b:match_words
+  else
+    execute "let match_words =" b:match_words
+  endif
+  if (match_words != s:last_words) || (&mps != s:last_mps) ||
+    \ exists("b:match_debug")
+    let s:last_words = match_words
+    let s:last_mps = &mps
+    if match_words !~ s:notslash . '\\\d'
+      let s:do_BR = 0
+      let s:pat = match_words
+    else
+      let s:do_BR = 1
+      let s:pat = s:ParseWords(match_words)
+    endif
+    let s:all = '\%(' . substitute(s:pat . (strlen(s:pat)?",":"") . default,
+      \        '[,:]\+','\\|','g') . '\)'
+    if exists("b:match_debug")
+      let b:match_pat = s:pat
+    endif
+  endif
+
+  " Second step:  figure out the patterns for searchpair()
+  " and save the screen, cursor position, and 'ignorecase'.
+  " - TODO:  A lot of this is copied from s:Match_wrapper().
+  " - maybe even more functionality should be split off
+  " - into separate functions!
+  let cdefault = (s:pat =~ '[^,]$' ? "," : "") . default
+  let open =  substitute(s:pat . cdefault,
+       \ s:notslash . '\zs:.\{-}' . s:notslash . ',', '\\),\\(', 'g')
+  let open =  '\(' . substitute(open, s:notslash . '\zs:.*$', '\\)', '')
+  let close = substitute(s:pat . cdefault,
+       \ s:notslash . '\zs,.\{-}' . s:notslash . ':', '\\),\\(', 'g')
+  let close = substitute(close, '^.\{-}' . s:notslash . ':', '\\(', '') . '\)'
+  if exists("b:match_skip")
+    let skip = b:match_skip
+  elseif exists("b:match_comment") " backwards compatibility and testing!
+    let skip = "r:" . b:match_comment
+  else
+    let skip = 's:comment\|string'
+  endif
+  let skip = s:ParseSkip(skip)
+  " let restore_cursor = line(".") . "G" . virtcol(".") . "|"
+  " normal! H
+  " let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
+  let restore_cursor = virtcol(".") . "|"
+  normal! g0
+  let restore_cursor = line(".") . "G" .  virtcol(".") . "|zs" . restore_cursor
+  normal! H
+  let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
+  execute restore_cursor
+
+  " Third step: call searchpair().
+  " Replace '\('--but not '\\('--with '\%(' and ',' with '\|'.
+  let openpat =  substitute(open, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
+  let openpat = substitute(openpat, ',', '\\|', 'g')
+  let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
+  let closepat = substitute(closepat, ',', '\\|', 'g')
+  if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
+    let skip = '0'
+  else
+    execute "if " . skip . "| let skip = '0' | endif"
+  endif
+  mark '
+  let level = v:count1
+  while level
+    if searchpair(openpat, '', closepat, a:spflag, skip) < 1
+      call s:CleanUp(restore_options, a:mode, startline, startcol)
+      return ""
+    endif
+    let level = level - 1
+  endwhile
+
+  " Restore options and return a string to restore the original position.
+  call s:CleanUp(restore_options, a:mode, startline, startcol)
+  return restore_cursor
+endfun
+
+" Search backwards for "if" or "while" or "<tag>" or ...
+" and return "endif" or "endwhile" or "</tag>" or ... .
+" For now, this uses b:match_words and the same script variables
+" as s:Match_wrapper() .  Later, it may get its own patterns,
+" either from a buffer variable or passed as arguments.
+" fun! s:Autocomplete()
+"   echo "autocomplete not yet implemented :-("
+"   if !exists("b:match_words") || b:match_words == ""
+"     return ""
+"   end
+"   let startpos = s:MultiMatch("bW")
+"
+"   if startpos == ""
+"     return ""
+"   endif
+"   " - TODO:  figure out whether 'if' or '<tag>' matched, and construct
+"   " - the appropriate closing.
+"   let matchline = getline(".")
+"   let curcol = col(".") - 1
+"   " - TODO:  Change the s:all argument if there is a new set of match pats.
+"   let regexp = s:Wholematch(matchline, s:all, curcol)
+"   let suf = strlen(matchline) - matchend(matchline, regexp)
+"   let prefix = (curcol ? '^.\{'  . curcol . '}\%(' : '^\%(')
+"   let suffix = (suf ? '\).\{' . suf . '}$'  : '\)$')
+"   " Reconstruct the version with unresolved backrefs.
+"   let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g')
+"   let patBR = substitute(patBR, ':\{2,}', ':', "g")
+"   " Now, set group and groupBR to the matching group: 'if:endif' or
+"   " 'while:endwhile' or whatever.
+"   let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR)
+"   let i = matchend(group, s:notslash . ",")
+"   let groupBR = strpart(group, i)
+"   let group = strpart(group, 0, i-1)
+"   " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
+"   if s:do_BR
+"     let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
+"   endif
+" " let g:group = group
+"
+"   " - TODO:  Construct the closing from group.
+"   let fake = "end" . expand("<cword>")
+"   execute startpos
+"   return fake
+" endfun
+
+" Close all open structures.  "Get the heck out of here!"
+" fun! s:Gthhoh()
+"   let close = s:Autocomplete()
+"   while strlen(close)
+"     put=close
+"     let close = s:Autocomplete()
+"   endwhile
+" endfun
+
+" Parse special strings as typical skip arguments for searchpair():
+"   s:foo becomes (current syntax item) =~ foo
+"   S:foo becomes (current syntax item) !~ foo
+"   r:foo becomes (line before cursor) =~ foo
+"   R:foo becomes (line before cursor) !~ foo
+fun! s:ParseSkip(str)
+  let skip = a:str
+  if skip[1] == ":"
+    if skip[0] == "s"
+      let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" .
+       \ strpart(skip,2) . "'"
+    elseif skip[0] == "S"
+      let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" .
+       \ strpart(skip,2) . "'"
+    elseif skip[0] == "r"
+      let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'"
+    elseif skip[0] == "R"
+      let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'"
+    endif
+  endif
+  return skip
+endfun
+
+let &cpo = s:save_cpo
+
+" vim:sts=2:sw=2:
diff --git a/vim/vim/bundle/nerdcommenter b/vim/vim/bundle/nerdcommenter
new file mode 160000 (submodule)
index 0000000..1f4bfd5
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 1f4bfd59920c101a30a74a07b824608a6e65f3fe
diff --git a/vim/vim/bundle/repeat b/vim/vim/bundle/repeat
new file mode 160000 (submodule)
index 0000000..7a6675f
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 7a6675f092842c8f81e71d5345bd7cdbf3759415
diff --git a/vim/vim/bundle/surround b/vim/vim/bundle/surround
new file mode 160000 (submodule)
index 0000000..2d05440
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 2d05440ad23f97a7874ebd9b5de3a0e65d25d85c
diff --git a/vim/vim/bundle/xptemplate b/vim/vim/bundle/xptemplate
new file mode 160000 (submodule)
index 0000000..beb1725
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit beb1725e57376caeb890df24c259a2e341ec69bd
diff --git a/vim/vim/colors/simon.vim b/vim/vim/colors/simon.vim
new file mode 100644 (file)
index 0000000..870c43b
--- /dev/null
@@ -0,0 +1,187 @@
+" Vim color scheme.
+"
+" Designed for dark and partially transparent terminals with 256 colors. It
+" works with GVim - however by default GVim doesn't support transparent
+" backgrounds, thus black is used as background color.
+"
+" Tested with xterm and (u)rxvt (both with -256color) and GVim.
+"
+" Not all available highlight groups are used at the moment.
+"
+" Some new highlight groups are defined which can be used in syntax files, see
+" "GENERAL ADDITIONS" below. They have to be configured to work.
+"
+" Maintainer:  Simon Ruderich <simon@ruderich.org>
+" Last Change: 2014-10-24
+" License:     GPL v3+
+
+" Copyright (C) 2011-2014  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" This color scheme only works with 256 colors and in GVim.
+if &t_Co != 256 && !has('gui_running')
+    echoerr 'Colorscheme "simon" needs 256 colors. Aborting.'
+    finish
+endif
+
+
+" This color scheme is (only) designed for a dark background.
+set background=dark
+highlight clear
+
+" :highlight clear resets this variable, so put it after it.
+let g:colors_name = 'simon'
+
+
+" GENERAL HIGHLIGHT SETTINGS
+
+" Normal text (very light gray on default terminal background). ctermbg=NONE
+" necessary for transparency. GVim doesn't support a transparent background,
+" thus use black.
+highlight Normal             ctermfg=252 ctermbg=NONE                           guifg=#d0d0d0 guibg=#000000
+
+" Comments (violet on default).
+highlight Comment            ctermfg=135                                        guifg=#af5fff
+" Constants (light dark red on default).
+highlight Constant           ctermfg=160                                        guifg=#d70000
+    " Strings, e.g. ".." (dark orange on default).
+    highlight String         ctermfg=208                                        guifg=#ff8700
+    " Characters, e.g. '.' in C (lighter dark orange on default).
+    highlight Character      ctermfg=215                                        guifg=#ffaf5f
+    " Numbers (light magenta on default).
+    highlight Number         ctermfg=207                                        guifg=#ff5fff
+    " Booleans (light dark red on default).
+    highlight Boolean        ctermfg=160                                        guifg=#d70000
+    highlight Float          ctermfg=207                                        guifg=#ff5fff
+" Identifier (cyan on default). cterm=NONE to prevent bold.
+highlight Identifier         ctermfg=51              cterm=NONE                 guifg=#00ffff               gui=NONE
+    " Function names, often used for predefined functions (cyan on default).
+    highlight Function       ctermfg=51              cterm=NONE                 guifg=#00ffff               gui=NONE
+" Statements, e.g. return, continue, etc. (yellow on default).
+highlight Statement          ctermfg=227             cterm=bold                 guifg=#ffff5f               gui=bold
+" Preprocessor commands, e.g. #include in cpp (light blue on default).
+highlight PreProc            ctermfg=63              cterm=bold                 guifg=#5f5fff               gui=bold
+" Types of variables, e.g. int, long, etc. (light green on default).
+highlight Type               ctermfg=83              cterm=bold                 guifg=#5fff5f               gui=bold
+    " static, volatile, etc. (lighter green on default).
+    highlight StorageClass   ctermfg=120             cterm=bold                 guifg=#87ff87               gui=bold
+" Special characters (red on default).
+highlight Special            ctermfg=160                                        guifg=#d70000
+    " Special characters in a string, e.g. '\n' (red on default).
+    highlight SpecialChar    ctermfg=160                                        guifg=#d70000
+    " Delimiter characters, e.g. braces around function arguments in some
+    " languages (dark red on default).
+    highlight Delimiter      ctermfg=52                                         guifg=#5f0000
+    " Special items inside a comment (light violent on darker violet).
+    highlight SpecialComment ctermfg=135 ctermbg=93                             guifg=#af5fff guibg=#8700ff
+" (Syntax) Errors (white on red).
+highlight Error              ctermfg=231 ctermbg=196                            guifg=#ffffff guibg=#ff0000
+" Todo items and other important stuff (e.g. TODO, XXX, etc.) (black on
+" yellow).
+highlight Todo               ctermfg=16  ctermbg=226                            guifg=#000000 guibg=#ffff00
+
+
+" Additional highlights used by the "GUI", not directly by syntax
+" highlighting.
+
+" Columns set with 'colorcolumn' (default on bright violet).
+highlight ColorColumn                    ctermbg=57                                           guibg=#5f00ff
+" Cursor color (black on light yellow).
+highlight Cursor             ctermfg=16  ctermbg=227                            guifg=#000000 guibg=#ffff5f
+" Cursor color when IME or XIM is on, :h CursorIM (not used, keep in sync with
+" Cursor).
+highlight CursorIM           ctermfg=16  ctermbg=227                            guifg=#000000 guibg=#ffff5f
+" Current cursor column/line (current color on dark gray). cterm=NONE to
+" prevent underlining.
+highlight CursorColumn                   ctermbg=234 cterm=NONE                 guibg=#1c1c1c               gui=NONE
+highlight CursorLine                     ctermbg=234 cterm=NONE                 guibg=#1c1c1c               gui=NONE
+" Directories in file listings (blue on default).
+highlight Directory          ctermfg=27              cterm=bold                 guifg=#005fff               gui=bold
+" Error messages (white on red).
+highlight ErrorMsg           ctermfg=231 ctermbg=196                            guifg=#ffffff guibg=#ff0000
+" Fold column, left of number column (lighter yellow on default), ctermbg=NONE
+" necessary for transparency.
+highlight FoldColumn         ctermfg=228 ctermbg=NONE                           guifg=#ffff87 guibg=NONE
+" Current search match during incremental search (black on orange).
+highlight IncSearch          ctermfg=16  ctermbg=214                            guifg=#000000 guibg=#ffaf00
+" Line number in line number column (light yellow on default).
+highlight LineNr             ctermfg=227                                        guifg=#ffff5f
+" Matching brace/bracket when the cursor is currently on the other one
+" (default on light green).
+highlight MatchParen                     ctermbg=40                                           guibg=#00d700
+" 'showmode' message, e.g. "-- INSERT --" (light gray on default).
+highlight ModeMsg            ctermfg=247                                        guifg=#9e9e9e
+" More prompt (:h more-prompt) (light green on default).
+highlight MoreMsg            ctermfg=119                                        guifg=#87ff5f
+" Characters which do not really exist in the text (:h NonText) (gray-like
+" blue on default).
+highlight NonText            ctermfg=105                                        guifg=#8787ff
+" Last search pattern for 'hlsearch' (keep in sync with IncSearch).
+highlight Search             ctermfg=16  ctermbg=214                            guifg=#000000 guibg=#ffaf00
+" Special characters, e.g. tabs, control characters (e.g. ^K), etc. (light
+" blue on default).
+highlight SpecialKey         ctermfg=69                                         guifg=#5f87ff
+" Spelling mistake (default on light violet).
+highlight SpellBad                       ctermbg=127                                          guibg=#af00af
+" Wrong capitalization (default on light blue).
+highlight SpellCap                       ctermbg=27                                           guibg=#005fff
+" Status line of the currently active window (bold and reverse).
+highlight StatusLine                                 cterm=reverse,bold                                     gui=reverse,bold
+" Status line of inactive windows (reverse).
+highlight StatusLineNC                               cterm=reverse                                          gui=reverse
+" Tab pages line, parts with no labels on the right (default, cterm=NONE to
+" disable reverse).
+highlight TabLineFill                                cterm=NONE                                             gui=NONE
+" Titles in output from :set all, :autocmd, etc. (light blue on default). Also
+" used by AsciiDoc.
+highlight Title              ctermfg=63              cterm=bold                 guifg=#5f5fff               gui=bold
+" Vertical split column (black on default), black to try to hide it
+" (ctermfg=NONE doesn't work), cterm=NONE is necessary to remove reverse. Also
+" see my vimrc for a way to hide it completely (the column is still there, but
+" empty).
+highlight VertSplit          ctermfg=16              cterm=NONE                 guifg=#000000               gui=NONE
+" Current visual selection (default on light gray).
+highlight Visual                         ctermbg=246                                          guibg=#949494
+" Warning messages (white on orange).
+highlight WarningMsg         ctermfg=231 ctermbg=166                            guifg=#ffffff guibg=#d75f00
+
+" Cursor color when language mappings are used, :h lCursor (not used, keep in
+" sync with Cursor).
+highlight lCursor            ctermfg=16  ctermbg=227                            guifg=#000000 guibg=#ffff5f
+
+
+" GENERAL ADDITIONS
+
+" Tab characters (if 'list' is enabled) to reduce their visibility in
+" comparison with SpecialKey (darker gray on default).
+"
+" Needs matchadd('specialKeyTab', '\t') in vimrc.
+highlight specialKeyTab      ctermfg=239                                        guifg=#4e4e4e
+
+" Statement control keywords (e.g. continue, break, return, goto, etc.), extra
+" syntax item to make them extra visible (keep in sync with Statement, except
+" underline).
+"
+" Needs a modified syntax file or additional rules in after/syntax/.
+"
+" For example for C:
+"
+"    syntax keyword statementControl continue break return goto
+"
+" Or for Perl:
+"
+"    highlight link perlStatementControl statementControl
+highlight statementControl   ctermfg=227             cterm=bold,underline       guifg=#ffff5f               gui=bold,underline
diff --git a/vim/vim/ftdetect/asciidoc_filetype.vim b/vim/vim/ftdetect/asciidoc_filetype.vim
new file mode 100644 (file)
index 0000000..9a936e0
--- /dev/null
@@ -0,0 +1,53 @@
+" Vim filetype detection file
+" Language:     AsciiDoc
+" Author:       Stuart Rackham <srackham@gmail.com>
+" Last Change:  AsciiDoc 8.2.0
+" URL:          http://www.methods.co.nz/asciidoc/
+" Licence:      GPL (http://www.gnu.org)
+" Remarks:      Vim 6 or greater
+
+" COMMENT OUT ONE OF THE TWO FOLLOWING COMMANDS
+" The first sets asciidoc syntax highlighting on all .txt files, the second
+" only existing files *.txt that appear to be AsciiDoc files.
+
+"au BufNewFile,BufRead *.txt,README,TODO,CHANGELOG,NOTES  setfiletype asciidoc
+au BufRead *.txt,README,TODO,CHANGELOG,NOTES call s:FTasciidoc()
+
+" This function checks for a valid AsciiDoc document title after first
+" skipping any leading comments.
+function! s:FTasciidoc()
+  let in_comment_block = 0
+  let n = 1
+  while n < 50
+    let line = getline(n)
+    let n = n + 1
+    if line =~ '^/\{4,}$'
+      if ! in_comment_block
+        let in_comment_block = 1
+      else
+        let in_comment_block = 0
+      endif
+      continue
+    endif
+    if in_comment_block
+      continue
+    endif
+    if line !~ '\(^//\)\|\(^\s*$\)'
+      break
+    endif
+  endwhile
+  if line !~ '.\{3,}'
+    return
+  endif
+  let len = len(line)
+  let line = getline(n)
+  if line !~ '[-=]\{3,}'
+    return
+  endif
+  if len < len(line) - 3 || len > len(line) + 3
+    return
+  endif
+  setfiletype asciidoc
+endfunction
+
+" vim: et sw=2 ts=2 sts=2:
diff --git a/vim/vim/ftdetect/vimperator.vim b/vim/vim/ftdetect/vimperator.vim
new file mode 100644 (file)
index 0000000..b7ee1a4
--- /dev/null
@@ -0,0 +1,2 @@
+" Vimperator
+au BufNewFile,BufRead *vimperatorrc*,*.vimp set filetype=vimperator
diff --git a/vim/vim/ftplugin/_common/personal.xpt.vim b/vim/vim/ftplugin/_common/personal.xpt.vim
new file mode 100644 (file)
index 0000000..9bcfb39
--- /dev/null
@@ -0,0 +1,47 @@
+" Custom settings for XPTemplate.
+XPTemplate priority=personal
+
+XPTvar $author     Simon Ruderich
+XPTvar $email      simon@ruderich.org
+
+
+" Space settings related to brackets.
+
+" if () ** {
+" else ** {
+XPTvar $BRif       ' '
+" } ** else {
+XPTvar $BRel       ' '
+" for () ** {
+" while () ** {
+" do ** {
+XPTvar $BRloop     ' '
+" struct name ** {
+XPTvar $BRstc      ' '
+" int fun() ** {
+" class name ** {
+XPTvar $BRfun      ' '
+
+
+" General space settings.
+
+" int fun ** (
+" class name ** (
+XPTvar $SPfun      ''
+
+" int fun( ** arg ** )
+" if ( ** condition ** )
+" for ( ** statement ** )
+" [ ** a, b ** ]
+" { ** 'k' : 'v' ** }
+XPTvar $SParg      ''
+
+" if ** (
+" while ** (
+" for ** (
+XPTvar $SPcmd      ' '
+
+" a ** = ** b
+" a = a ** + ** 1
+" (a, ** b, ** )
+XPTvar $SPop       ' '
diff --git a/vim/vim/ftplugin/c/c.xpt.vim b/vim/vim/ftplugin/c/c.xpt.vim
new file mode 100644 (file)
index 0000000..aaeb7db
--- /dev/null
@@ -0,0 +1,69 @@
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language:     C
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012-2014  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+    finish
+endif
+
+XPTemplate priority=personal
+
+
+XPT f
+XSET description|post=S(V(), '^description$', 'XXX')
+/*
+ * `description^
+ *
+ * Copyright (C) `strftime("%Y")^  Simon Ruderich
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int main(int argc, char **argv) {
+    `cursor^
+
+    return EXIT_SUCCESS;
+}
+
+
+XPT p
+printf("`format^"`cursor^);
+
+XPT pe
+fprintf(stderr, "`format^"`cursor^);
diff --git a/vim/vim/ftplugin/java/java.xpt.vim b/vim/vim/ftplugin/java/java.xpt.vim
new file mode 100644 (file)
index 0000000..c6749c8
--- /dev/null
@@ -0,0 +1,64 @@
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language:     Java
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012-2014  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+    finish
+endif
+
+XPTemplate priority=personal
+
+
+XPT f
+XSET description|post=S(V(), '^description$', 'XXX')
+/*
+ * `description^
+ *
+ * Copyright (C) `strftime("%Y")^  Simon Ruderich
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+public class `E('%:t:r')^ {
+    `cursor^
+}
+
+
+XPT p
+System.out.println(`value^);
+
+XPT pe
+System.err.println(`value^);
diff --git a/vim/vim/ftplugin/perl/perl.xpt.vim b/vim/vim/ftplugin/perl/perl.xpt.vim
new file mode 100644 (file)
index 0000000..c2b4314
--- /dev/null
@@ -0,0 +1,78 @@
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language:     Perl
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012-2014  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+    finish
+endif
+
+XPTemplate priority=personal
+
+
+XPT f
+XSET description|post=S(V(), '^description$', 'XXX')
+#!/usr/bin/perl
+
+# `description^
+
+# Copyright (C) `strftime("%Y")^  Simon Ruderich
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+use strict;
+use warnings;
+
+
+`cursor^
+
+
+XPT p
+print `value^;
+
+XPT pe
+print STDERR `value^;
+
+XPT pd
+print Dumper(`value^);
+
+
+XPT u
+use `package^;
+`cursor^
+
+XPT udd
+use Data::Dumper;
+`cursor^
diff --git a/vim/vim/ftplugin/tex/tex.xpt.vim b/vim/vim/ftplugin/tex/tex.xpt.vim
new file mode 100644 (file)
index 0000000..a7173c1
--- /dev/null
@@ -0,0 +1,97 @@
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language:     LaTeX
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2012  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" Prevent errors if XPTemplate is not installed.
+if !exists('g:XPT#ver')
+    finish
+endif
+
+XPTemplate priority=personal
+
+
+" PACKAGES
+
+XPT usepackage " \usepackage{..}
+\usepackage{`package^}
+
+
+" SECTIONS
+
+XPT s synonym=section " \section{..}
+\section`*^{`title^}
+
+XPT ss " \subsection{..}
+\subsection`*^{`title^}
+
+XPT sss " \subsubsection{..}
+\subsubsection`*^{`title^}
+
+
+" ENVIRONMENTS
+
+XPT itemize " \begin{itemize} .. \end{itemize}
+\begin{itemize}
+\item `cursor^
+\end{itemize}
+
+XPT enumerate " \begin{enumerate} .. \end{enumerate}
+\begin{enumerate}
+\item `cursor^
+\end{enumerate}
+
+XPT description " \begin{description} .. \end{description}
+\begin{description}
+\item`[`text?`]^ `cursor^
+\end{description}
+
+XPT i "\item ..
+\item`[`text?`]^ `cursor^
+
+XPT align " \begin{align} .. \end{align}
+\begin{align`*^}
+`cursor^
+\end{align`*^}
+
+XPT listing " \begin{lstlisting} .. \end{lstlisting}
+\begin{lstlisting}`[`attributes?`]^
+`cursor^
+\end{lstlisting}
+
+
+" BEAMER
+
+XPT frame " \begin{frame} .. \end{frame}
+\begin{frame}{`title^}
+`cursor^
+\end{frame}
+
+XPT block " \begin{block} .. \end{block}
+\begin{block}{`title^}
+`cursor^
+\end{block}
+
+XPT exampleblock " \begin{exampleblock} .. \end{exampleblock}
+\begin{exampleblock}{`title^}
+`cursor^
+\end{exampleblock}
diff --git a/vim/vim/ftplugin/vhdl/vhdl.xpt.vim b/vim/vim/ftplugin/vhdl/vhdl.xpt.vim
new file mode 100644 (file)
index 0000000..6707b9c
--- /dev/null
@@ -0,0 +1,67 @@
+" vim: ft=xpt
+
+" XPTemplate template file.
+"
+" Language:     VHDL
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" License:      GPL v3+
+
+" Copyright (C) 2014  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+XPTemplate priority=lang
+
+let s:f = g:XPTfuncs()
+
+XPTinclude
+      \ _common/common
+
+
+XPT f
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+`cursor^
+
+
+XPT slv
+std_logic_vector(`from^ downto `to^)
+
+
+XPT entity
+entity `name^ is
+    port(
+        `cursor^
+    );
+end entity;
+
+XPT architecture
+architecture `behavioral^ of `entity^ is
+begin
+    `cursor^
+end architecture;
+
+XPT process
+process`list^
+begin
+    `cursor^
+end process;
+
+XPT if
+if `condition^ then
+    `cursor^
+end if;
diff --git a/vim/vim/plugin/gnupg.vim b/vim/vim/plugin/gnupg.vim
new file mode 100644 (file)
index 0000000..3b00366
--- /dev/null
@@ -0,0 +1,1464 @@
+" Name:    gnupg.vim
+" Last Change: 2015 Dec 17
+" Maintainer:  James McCoy <vega.james@gmail.com>
+" Original Author:  Markus Braun <markus.braun@krawel.de>
+" Summary: Vim plugin for transparent editing of gpg encrypted files.
+" License: This program is free software; you can redistribute it and/or
+"          modify it under the terms of the GNU General Public License
+"          as published by the Free Software Foundation; either version
+"          2 of the License, or (at your option) any later version.
+"          See http://www.gnu.org/copyleft/gpl-2.0.txt
+"
+" Section: Documentation {{{1
+"
+" Description: {{{2
+"
+"   This script implements transparent editing of gpg encrypted files. The
+"   filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such
+"   a file the content is decrypted, when opening a new file the script will
+"   ask for the recipients of the encrypted file. The file content will be
+"   encrypted to all recipients before it is written. The script turns off
+"   viminfo, swapfile, and undofile to increase security.
+"
+" Installation: {{{2
+"
+"   Copy the gnupg.vim file to the $HOME/.vim/plugin directory.
+"   Refer to ':help add-plugin', ':help add-global-plugin' and ':help
+"   runtimepath' for more details about Vim plugins.
+"
+"   From "man 1 gpg-agent":
+"
+"   ...
+"   You should always add the following lines to your .bashrc or whatever
+"   initialization file is used for all shell invocations:
+"
+"        GPG_TTY=`tty`
+"        export GPG_TTY
+"
+"   It is important that this environment variable always reflects the out‐
+"   put of the tty command. For W32 systems this option is not required.
+"   ...
+"
+"   Most distributions provide software to ease handling of gpg and gpg-agent.
+"   Examples are keychain or seahorse.
+"
+"   If there are specific actions that should take place when editing a
+"   GnuPG-managed buffer, an autocmd for the User event and GnuPG pattern can
+"   be defined.  For example, the following will set 'textwidth' to 72 for all
+"   GnuPG-encrypted buffers:
+"
+"       autocmd User GnuPG setl textwidth=72
+"
+"   This will be triggered before any BufRead or BufNewFile autocmds, and
+"   therefore will not take precedence over settings specific to any filetype
+"   that may get set.
+"
+" Commands: {{{2
+"
+"   :GPGEditRecipients
+"     Opens a scratch buffer to change the list of recipients. Recipients that
+"     are unknown (not in your public key) are highlighted and have
+"     a prepended "!". Closing the buffer makes the changes permanent.
+"
+"   :GPGViewRecipients
+"     Prints the list of recipients.
+"
+"   :GPGEditOptions
+"     Opens a scratch buffer to change the options for encryption (symmetric,
+"     asymmetric, signing). Closing the buffer makes the changes permanent.
+"     WARNING: There is no check of the entered options, so you need to know
+"     what you are doing.
+"
+"   :GPGViewOptions
+"     Prints the list of options.
+"
+" Variables: {{{2
+"
+"   g:GPGExecutable
+"     If set used as gpg executable. If unset, defaults to
+"     "gpg --trust-model always" if "gpg" is available, falling back to
+"     "gpg2 --trust-model always" if not.
+"
+"   g:GPGUseAgent
+"     If set to 0 a possible available gpg-agent won't be used. Defaults to 1.
+"
+"   g:GPGPreferSymmetric
+"     If set to 1 symmetric encryption is preferred for new files. Defaults to 0.
+"
+"   g:GPGPreferArmor
+"     If set to 1 armored data is preferred for new files. Defaults to 0
+"     unless a "*.asc" file is being edited.
+"
+"   g:GPGPreferSign
+"     If set to 1 signed data is preferred for new files. Defaults to 0.
+"
+"   g:GPGDefaultRecipients
+"     If set, these recipients are used as defaults when no other recipient is
+"     defined. This variable is a Vim list. Default is unset.
+"
+"   g:GPGPossibleRecipients
+"     If set, these contents are loaded into the recipients dialog. This
+"     allows to add commented lines with possible recipients to the list,
+"     which can be uncommented to select the actual recipients. Default is
+"     unset. Example:
+"
+"       let g:GPGPossibleRecipients=[
+"         \"Example User <example@example.com>",
+"         \"Other User <otherexample@example.com>"
+"       \]
+"
+"
+"   g:GPGUsePipes
+"     If set to 1, use pipes instead of temporary files when interacting with
+"     gnupg.  When set to 1, this can cause terminal-based gpg agents to not
+"     display correctly when prompting for passwords.  Defaults to 0.
+"
+"   g:GPGHomedir
+"     If set, specifies the directory that will be used for GPG's homedir.
+"     This corresponds to gpg's --homedir option.  This variable is a Vim
+"     string. Default is unset.
+"
+"   g:GPGFilePattern
+"     If set, overrides the default set of file patterns that determine
+"     whether this plugin will be activated.  Defaults to
+"     '*.\(gpg\|asc\|pgp\)'.
+"
+" Known Issues: {{{2
+"
+"   In some cases gvim can't decrypt files
+
+"   This is caused by the fact that a running gvim has no TTY and thus gpg is
+"   not able to ask for the passphrase by itself. This is a problem for Windows
+"   and Linux versions of gvim and could not be solved unless a "terminal
+"   emulation" is implemented for gvim. To circumvent this you have to use any
+"   combination of gpg-agent and a graphical pinentry program:
+"
+"     - gpg-agent only:
+"         you need to provide the passphrase for the needed key to gpg-agent
+"         in a terminal before you open files with gvim which require this key.
+"
+"     - pinentry only:
+"         you will get a popup window every time you open a file that needs to
+"         be decrypted.
+"
+"     - gpgagent and pinentry:
+"         you will get a popup window the first time you open a file that
+"         needs to be decrypted.
+"
+"   If you're using Vim <7.4.959, after the plugin runs any external command,
+"   Vim will no longer be able to yank to/paste from the X clipboard or
+"   primary selections.  This is caused by a workaround for a different bug
+"   where Vim no longer recognizes the key codes for keys such as the arrow
+"   keys after running GnuPG.  See the discussion at
+"   https://github.com/jamessan/vim-gnupg/issues/36 for more details.
+"
+" Credits: {{{2
+"
+"   - Mathieu Clabaut for inspirations through his vimspell.vim script.
+"   - Richard Bronosky for patch to enable ".pgp" suffix.
+"   - Erik Remmelzwaal for patch to enable windows support and patient beta
+"     testing.
+"   - Lars Becker for patch to make gpg2 working.
+"   - Thomas Arendsen Hein for patch to convert encoding of gpg output.
+"   - Karl-Heinz Ruskowski for patch to fix unknown recipients and trust model
+"     and patient beta testing.
+"   - Giel van Schijndel for patch to get GPG_TTY dynamically.
+"   - Sebastian Luettich for patch to fix issue with symmetric encryption an set
+"     recipients.
+"   - Tim Swast for patch to generate signed files.
+"   - James Vega for patches for better '*.asc' handling, better filename
+"     escaping and better handling of multiple keyrings.
+"
+" Section: Plugin header {{{1
+
+" guard against multiple loads {{{2
+if (exists("g:loaded_gnupg") || &cp || exists("#GnuPG"))
+  finish
+endif
+let g:loaded_gnupg = '2.5'
+let s:GPGInitRun = 0
+
+" check for correct vim version {{{2
+if (v:version < 702)
+  echohl ErrorMsg | echo 'plugin gnupg.vim requires Vim version >= 7.2' | echohl None
+  finish
+endif
+
+" Section: Autocmd setup {{{1
+
+if (!exists("g:GPGFilePattern"))
+  let g:GPGFilePattern = '*.\(gpg\|asc\|pgp\)'
+endif
+
+augroup GnuPG
+  autocmd!
+
+  " do the decryption
+  exe "autocmd BufReadCmd " . g:GPGFilePattern .  " call s:GPGInit(1) |" .
+                                                \ " call s:GPGDecrypt(1)"
+  exe "autocmd FileReadCmd " . g:GPGFilePattern . " call s:GPGInit(0) |" .
+                                                \ " call s:GPGDecrypt(0)"
+
+  " convert all text to encrypted text before writing
+  " We check for GPGCorrespondingTo to avoid triggering on writes in GPG Options/Recipient windows
+  exe "autocmd BufWriteCmd,FileWriteCmd " . g:GPGFilePattern . " if !exists('b:GPGCorrespondingTo') |" .
+                                                             \ " call s:GPGInit(0) |" .
+                                                             \ " call s:GPGEncrypt() |" .
+                                                             \ " endif"
+
+  " cleanup on leaving vim
+  exe "autocmd VimLeave " . g:GPGFilePattern .    " call s:GPGCleanup()"
+augroup END
+
+" Section: Constants {{{1
+
+let s:GPGMagicString = "\t \t"
+let s:keyPattern = '\%(0x\)\=[[:xdigit:]]\{8,16}'
+
+" Section: Highlight setup {{{1
+
+highlight default link GPGWarning WarningMsg
+highlight default link GPGError ErrorMsg
+highlight default link GPGHighlightUnknownRecipient ErrorMsg
+
+" Section: Functions {{{1
+
+" Function: s:shellescape(s[, special]) {{{2
+"
+" Calls shellescape(), also taking into account 'shellslash'
+" when on Windows and using $COMSPEC as the shell.
+"
+" Returns: shellescaped string
+"
+function s:shellescape(s, ...)
+  let special = a:0 ? a:1 : 0
+  if exists('+shellslash') && &shell == $COMSPEC
+    let ssl = &shellslash
+    set noshellslash
+
+    let escaped = shellescape(a:s, special)
+
+    let &shellslash = ssl
+  else
+    let escaped = shellescape(a:s, special)
+  endif
+
+  return escaped
+endfunction
+
+" Function: s:GPGInit(bufread) {{{2
+"
+" initialize the plugin
+" The bufread argument specifies whether this was called due to BufReadCmd
+"
+function s:GPGInit(bufread)
+  call s:GPGDebug(3, printf(">>>>>>>> Entering s:GPGInit(%d)", a:bufread))
+
+  " For FileReadCmd, we're reading the contents into another buffer.  If that
+  " buffer is also destined to be encrypted, then these settings will have
+  " already been set, otherwise don't set them since it limits the
+  " functionality of the cleartext buffer.
+  if a:bufread
+    " we don't want a swap file, as it writes unencrypted data to disk
+    setl noswapfile
+
+    " if persistent undo is present, disable it for this buffer
+    if exists('+undofile')
+      setl noundofile
+    endif
+
+    " first make sure nothing is written to ~/.viminfo while editing
+    " an encrypted file.
+    set viminfo=
+  endif
+
+  " the rest only has to be run once
+  if s:GPGInitRun
+    return
+  endif
+
+  " check what gpg command to use
+  if (!exists("g:GPGExecutable"))
+    if executable("gpg")
+      let g:GPGExecutable = "gpg --trust-model always"
+    else
+      let g:GPGExecutable = "gpg2 --trust-model always"
+    endif
+  endif
+
+  " check if gpg-agent is allowed
+  if (!exists("g:GPGUseAgent"))
+    let g:GPGUseAgent = 1
+  endif
+
+  " check if symmetric encryption is preferred
+  if (!exists("g:GPGPreferSymmetric"))
+    let g:GPGPreferSymmetric = 0
+  endif
+
+  " check if armored files are preferred
+  if (!exists("g:GPGPreferArmor"))
+    " .asc files should be armored as that's what the extension is used for
+    if expand('<afile>') =~ '\.asc$'
+      let g:GPGPreferArmor = 1
+    else
+      let g:GPGPreferArmor = 0
+    endif
+  endif
+
+  " check if signed files are preferred
+  if (!exists("g:GPGPreferSign"))
+    let g:GPGPreferSign = 0
+  endif
+
+  " start with empty default recipients if none is defined so far
+  if (!exists("g:GPGDefaultRecipients"))
+    let g:GPGDefaultRecipients = []
+  endif
+
+  if (!exists("g:GPGPossibleRecipients"))
+    let g:GPGPossibleRecipients = []
+  endif
+
+
+  " prefer not to use pipes since it can garble gpg agent display
+  if (!exists("g:GPGUsePipes"))
+    let g:GPGUsePipes = 0
+  endif
+
+  " allow alternate gnupg homedir
+  if (!exists('g:GPGHomedir'))
+    let g:GPGHomedir = ''
+  endif
+
+  " print version
+  call s:GPGDebug(1, "gnupg.vim ". g:loaded_gnupg)
+
+  let s:GPGCommand = g:GPGExecutable
+
+  " don't use tty in gvim except for windows: we get their a tty for free.
+  " FIXME find a better way to avoid an error.
+  "       with this solution only --use-agent will work
+  if (has("gui_running") && !has("gui_win32"))
+    let s:GPGCommand .= " --no-tty"
+  endif
+
+  " setup shell environment for unix and windows
+  let s:shellredirsave = &shellredir
+  let s:shellsave = &shell
+  let s:shelltempsave = &shelltemp
+  " noshelltemp isn't currently supported on Windows, but it doesn't cause any
+  " errors and this future proofs us against requiring changes if Windows
+  " gains noshelltemp functionality
+  let s:shelltemp = !g:GPGUsePipes
+  if (has("unix"))
+    " unix specific settings
+    let s:shellredir = ">%s 2>&1"
+    let s:shell = '/bin/sh'
+    let s:stderrredirnull = '2>/dev/null'
+  else
+    " windows specific settings
+    let s:shellredir = '>%s'
+    let s:shell = &shell
+    let s:stderrredirnull = '2>nul'
+  endif
+
+  call s:GPGDebug(3, "shellredirsave: " . s:shellredirsave)
+  call s:GPGDebug(3, "shellsave: " . s:shellsave)
+  call s:GPGDebug(3, "shelltempsave: " . s:shelltempsave)
+
+  call s:GPGDebug(3, "shell: " . s:shell)
+  call s:GPGDebug(3, "shellcmdflag: " . &shellcmdflag)
+  call s:GPGDebug(3, "shellxquote: " . &shellxquote)
+  call s:GPGDebug(3, "shellredir: " . s:shellredir)
+  call s:GPGDebug(3, "stderrredirnull: " . s:stderrredirnull)
+
+  call s:GPGDebug(3, "shell implementation: " . resolve(s:shell))
+
+  " find the supported algorithms
+  let output = s:GPGSystem({ 'level': 2, 'args': '--version' })
+
+  let gpgversion = substitute(output, '^gpg (GnuPG) \([0-9]\+\.\d\+\).*', '\1', '')
+  let s:GPGPubkey = substitute(output, ".*Pubkey: \\(.\\{-}\\)\n.*", "\\1", "")
+  let s:GPGCipher = substitute(output, ".*Cipher: \\(.\\{-}\\)\n.*", "\\1", "")
+  let s:GPGHash = substitute(output, ".*Hash: \\(.\\{-}\\)\n.*", "\\1", "")
+  let s:GPGCompress = substitute(output, ".*Compress.\\{-}: \\(.\\{-}\\)\n.*", "\\1", "")
+
+  " determine if gnupg can use the gpg-agent
+  if (str2float(gpgversion) >= 2.1 || (exists("$GPG_AGENT_INFO") && g:GPGUseAgent == 1))
+    if (!exists("$GPG_TTY") && !has("gui_running"))
+      " Need to determine the associated tty by running a command in the
+      " shell.  We can't use system() here because that doesn't run in a shell
+      " connected to a tty, so it's rather useless.
+      "
+      " Save/restore &modified so the buffer isn't incorrectly marked as
+      " modified just by detecting the correct tty value.
+      " Do the &undolevels dance so the :read and :delete don't get added into
+      " the undo tree, as the user needn't be aware of these.
+      let [mod, levels] = [&l:modified, &undolevels]
+      set undolevels=-1
+      silent read !tty
+      let $GPG_TTY = getline('.')
+      silent delete
+      let [&l:modified, &undolevels] = [mod, levels]
+      " redraw is needed since we're using silent to run !tty, c.f. :help :!
+      redraw!
+      if (v:shell_error)
+        let $GPG_TTY = ""
+        echohl GPGWarning
+        echom "$GPG_TTY is not set and the `tty` command failed! gpg-agent might not work."
+        echohl None
+      endif
+    endif
+    let s:GPGCommand .= " --use-agent"
+  else
+    let s:GPGCommand .= " --no-use-agent"
+  endif
+
+  call s:GPGDebug(2, "public key algorithms: " . s:GPGPubkey)
+  call s:GPGDebug(2, "cipher algorithms: " . s:GPGCipher)
+  call s:GPGDebug(2, "hashing algorithms: " . s:GPGHash)
+  call s:GPGDebug(2, "compression algorithms: " . s:GPGCompress)
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGInit()")
+  let s:GPGInitRun = 1
+endfunction
+
+" Function: s:GPGCleanup() {{{2
+"
+" cleanup on leaving vim
+"
+function s:GPGCleanup()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGCleanup()")
+
+  " wipe out screen
+  new +only
+  redraw!
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGCleanup()")
+endfunction
+
+" Function: s:GPGDecrypt(bufread) {{{2
+"
+" decrypt the buffer and find all recipients of the encrypted file
+" The bufread argument specifies whether this was called due to BufReadCmd
+"
+function s:GPGDecrypt(bufread)
+  call s:GPGDebug(3, printf(">>>>>>>> Entering s:GPGDecrypt(%d)", a:bufread))
+
+  " get the filename of the current buffer
+  let filename = expand("<afile>:p")
+
+  " clear GPGRecipients and GPGOptions
+  if type(g:GPGDefaultRecipients) == type([])
+    let b:GPGRecipients = copy(g:GPGDefaultRecipients)
+  else
+    let b:GPGRecipients = []
+    echohl GPGWarning
+    echom "g:GPGDefaultRecipients is not a Vim list, please correct this in your vimrc!"
+    echohl None
+  endif
+  let b:GPGOptions = []
+
+  " file name minus extension
+  let autocmd_filename = fnameescape(expand('<afile>:r'))
+
+  " File doesn't exist yet, so nothing to decrypt
+  if !filereadable(filename)
+    " Allow the user to define actions for GnuPG buffers
+    silent doautocmd User GnuPG
+    " call the autocommand for the file minus .gpg$
+    silent execute ':doautocmd BufNewFile ' . autocmd_filename
+    call s:GPGDebug(2, 'called BufNewFile autocommand for ' . autocmd_filename)
+
+    " This is a new file, so force the user to edit the recipient list if
+    " they open a new file and public keys are preferred
+    if (g:GPGPreferSymmetric == 0)
+        call s:GPGEditRecipients()
+    endif
+
+    return
+  endif
+
+  " Only let this if the file actually exists, otherwise GPG functionality
+  " will be disabled when editing a buffer that doesn't yet have a backing
+  " file
+  let b:GPGEncrypted = 0
+
+  " find the recipients of the file
+  let cmd = { 'level': 3 }
+  let cmd.args = '--verbose --decrypt --list-only --dry-run --no-use-agent --logger-fd 1 ' . s:shellescape(filename)
+  let output = s:GPGSystem(cmd)
+
+  " Suppress the "N more lines" message when editing a file, not when reading
+  " the contents of a file into a buffer
+  let silent = a:bufread ? 'silent ' : ''
+
+  let asymmPattern = 'gpg: public key is ' . s:keyPattern
+  " check if the file is symmetric/asymmetric encrypted
+  if (match(output, "gpg: encrypted with [[:digit:]]\\+ passphrase") >= 0)
+    " file is symmetric encrypted
+    let b:GPGEncrypted = 1
+    call s:GPGDebug(1, "this file is symmetric encrypted")
+
+    let b:GPGOptions += ["symmetric"]
+
+    " find the used cipher algorithm
+    let cipher = substitute(output, ".*gpg: \\([^ ]\\+\\) encrypted data.*", "\\1", "")
+    if (match(s:GPGCipher, "\\<" . cipher . "\\>") >= 0)
+      let b:GPGOptions += ["cipher-algo " . cipher]
+      call s:GPGDebug(1, "cipher-algo is " . cipher)
+    else
+      echohl GPGWarning
+      echom "The cipher " . cipher . " is not known by the local gpg command. Using default!"
+      echo
+      echohl None
+    endif
+  elseif (match(output, asymmPattern) >= 0)
+    " file is asymmetric encrypted
+    let b:GPGEncrypted = 1
+    call s:GPGDebug(1, "this file is asymmetric encrypted")
+
+    let b:GPGOptions += ["encrypt"]
+
+    " find the used public keys
+    let start = match(output, asymmPattern)
+    while (start >= 0)
+      let start = start + strlen("gpg: public key is ")
+      let recipient = matchstr(output, s:keyPattern, start)
+      call s:GPGDebug(1, "recipient is " . recipient)
+      " In order to support anonymous communication, GnuPG allows eliding
+      " information in the encryption metadata specifying what keys the file
+      " was encrypted to (c.f., --throw-keyids and --hidden-recipient).  In
+      " that case, the recipient(s) will be listed as having used a key of all
+      " zeroes.
+      " Since this will obviously never actually be in a keyring, only try to
+      " convert to an ID or add to the recipients list if it's not a hidden
+      " recipient.
+      if recipient !~? '^0x0\+$'
+        let name = s:GPGNameToID(recipient)
+        if !empty(name)
+          let b:GPGRecipients += [name]
+          call s:GPGDebug(1, "name of recipient is " . name)
+        else
+          let b:GPGRecipients += [recipient]
+          echohl GPGWarning
+          echom "The recipient \"" . recipient . "\" is not in your public keyring!"
+          echohl None
+        end
+      end
+      let start = match(output, asymmPattern, start)
+    endwhile
+  else
+    " file is not encrypted
+    let b:GPGEncrypted = 0
+    call s:GPGDebug(1, "this file is not encrypted")
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    exe printf('%sr %s', silent, fnameescape(filename))
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
+    return
+  endif
+
+  if a:bufread
+    silent execute ':doautocmd BufReadPre ' . autocmd_filename
+    call s:GPGDebug(2, 'called BufReadPre autocommand for ' . autocmd_filename)
+  else
+    silent execute ':doautocmd FileReadPre ' . autocmd_filename
+    call s:GPGDebug(2, 'called FileReadPre autocommand for ' . autocmd_filename)
+  endif
+
+  " check if the message is armored
+  if (match(output, "gpg: armor header") >= 0)
+    call s:GPGDebug(1, "this file is armored")
+    let b:GPGOptions += ["armor"]
+  endif
+
+  " finally decrypt the buffer content
+  " since even with the --quiet option passphrase typos will be reported,
+  " we must redirect stderr (using shell temporarily)
+  call s:GPGDebug(1, "decrypting file")
+  let cmd = { 'level': 1, 'ex': silent . 'r !' }
+  let cmd.args = '--quiet --decrypt ' . s:shellescape(filename, 1)
+  call s:GPGExecute(cmd)
+
+  if (v:shell_error) " message could not be decrypted
+    echohl GPGError
+    let blackhole = input("Message could not be decrypted! (Press ENTER)")
+    echohl None
+    " Only wipeout the buffer if we were creating one to start with.
+    " FileReadCmd just reads the content into the existing buffer
+    if a:bufread
+      silent bwipeout!
+    endif
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
+    return
+  endif
+
+  if a:bufread
+    " In order to make :undo a no-op immediately after the buffer is read,
+    " we need to do this dance with 'undolevels'.  Actually discarding the undo
+    " history requires performing a change after setting 'undolevels' to -1 and,
+    " luckily, we have one we need to do (delete the extra line from the :r
+    " command)
+    let levels = &undolevels
+    set undolevels=-1
+    " :lockmarks doesn't actually prevent '[,'] from being overwritten, so we
+    " need to manually set them ourselves instead
+    silent 1delete
+    1mark [
+    $mark ]
+    let &undolevels = levels
+    let &readonly = filereadable(filename) && filewritable(filename) == 0
+    " call the autocommand for the file minus .gpg$
+    silent execute ':doautocmd BufReadPost ' . autocmd_filename
+    call s:GPGDebug(2, 'called BufReadPost autocommand for ' . autocmd_filename)
+  else
+    " call the autocommand for the file minus .gpg$
+    silent execute ':doautocmd FileReadPost ' . autocmd_filename
+    call s:GPGDebug(2, 'called FileReadPost autocommand for ' . autocmd_filename)
+  endif
+
+  " Allow the user to define actions for GnuPG buffers
+  silent doautocmd User GnuPG
+
+  " refresh screen
+  redraw!
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
+endfunction
+
+" Function: s:GPGEncrypt() {{{2
+"
+" encrypts the buffer to all previous recipients
+"
+function s:GPGEncrypt()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEncrypt()")
+
+  " FileWriteCmd is only called when a portion of a buffer is being written to
+  " disk.  Since Vim always sets the '[,'] marks to the part of a buffer that
+  " is being written, that can be used to determine whether BufWriteCmd or
+  " FileWriteCmd triggered us.
+  if [line("'["), line("']")] == [1, line('$')]
+    let auType = 'BufWrite'
+  else
+    let auType = 'FileWrite'
+  endif
+
+  " file name minus extension
+  let autocmd_filename = fnameescape(expand('<afile>:r'))
+
+  silent exe ':doautocmd '. auType .'Pre '. autocmd_filename
+  call s:GPGDebug(2, 'called '. auType .'Pre autocommand for ' . autocmd_filename)
+
+  " store encoding and switch to a safe one
+  if (&fileencoding != &encoding)
+    let s:GPGEncoding = &encoding
+    let &encoding = &fileencoding
+    call s:GPGDebug(2, "encoding was \"" . s:GPGEncoding . "\", switched to \"" . &encoding . "\"")
+  else
+    let s:GPGEncoding = ""
+    call s:GPGDebug(2, "encoding and fileencoding are the same (\"" . &encoding . "\"), not switching")
+  endif
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGError
+    let blackhole = input("Message could not be encrypted! (Press ENTER)")
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
+    return
+  endif
+
+  " initialize GPGOptions if not happened before
+  if (!exists("b:GPGOptions") || empty(b:GPGOptions))
+    let b:GPGOptions = []
+    if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 1)
+      let b:GPGOptions += ["symmetric"]
+      let b:GPGRecipients = []
+    else
+      let b:GPGOptions += ["encrypt"]
+    endif
+    if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1)
+      let b:GPGOptions += ["armor"]
+    endif
+    if (exists("g:GPGPreferSign") && g:GPGPreferSign == 1)
+      let b:GPGOptions += ["sign"]
+    endif
+    call s:GPGDebug(1, "no options set, so using default options: " . string(b:GPGOptions))
+  endif
+
+  " built list of options
+  let options = ""
+  for option in b:GPGOptions
+    let options = options . " --" . option . " "
+  endfor
+
+  if (!exists('b:GPGRecipients'))
+    let b:GPGRecipients = []
+  endif
+
+  " check here again if all recipients are available in the keyring
+  let recipients = s:GPGCheckRecipients(b:GPGRecipients)
+
+  " check if there are unknown recipients and warn
+  if !empty(recipients.unknown)
+    echohl GPGWarning
+    echom "Please use GPGEditRecipients to correct!!"
+    echo
+    echohl None
+
+    " Let user know whats happend and copy known_recipients back to buffer
+    let dummy = input("Press ENTER to quit")
+  endif
+
+  " built list of recipients
+  let options .= ' ' . join(map(recipients.valid, '"-r ".v:val'), ' ')
+
+  " encrypt the buffer
+  let destfile = tempname()
+  let cmd = { 'level': 1, 'ex': "'[,']w !" }
+  let cmd.args = '--quiet --no-encrypt-to ' . options
+  let cmd.redirect = '>' . s:shellescape(destfile, 1)
+  silent call s:GPGExecute(cmd)
+
+  " restore encoding
+  if (s:GPGEncoding != "")
+    let &encoding = s:GPGEncoding
+    call s:GPGDebug(2, "restored encoding \"" . &encoding . "\"")
+  endif
+
+  if (v:shell_error) " message could not be encrypted
+    " Command failed, so clean up the tempfile
+    call delete(destfile)
+    echohl GPGError
+    let blackhole = input("Message could not be encrypted! (Press ENTER)")
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
+    return
+  endif
+
+  let filename = resolve(expand('<afile>'))
+  if rename(destfile, filename)
+    " Rename failed, so clean up the tempfile
+    call delete(destfile)
+    echohl GPGError
+    echom printf("\"%s\" E212: Can't open file for writing", filename)
+    echohl None
+    return
+  endif
+
+  if auType == 'BufWrite'
+    setl nomodified
+    let &readonly = filereadable(filename) && filewritable(filename) == 0
+  endif
+
+  silent exe ':doautocmd '. auType .'Post '. autocmd_filename
+  call s:GPGDebug(2, 'called '. auType .'Post autocommand for ' . autocmd_filename)
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
+endfunction
+
+" Function: s:GPGViewRecipients() {{{2
+"
+" echo the recipients
+"
+function s:GPGViewRecipients()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewRecipients()")
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewRecipients()")
+    return
+  endif
+
+  let recipients = s:GPGCheckRecipients(b:GPGRecipients)
+
+  echo 'This file has following recipients (Unknown recipients have a prepended "!"):'
+  " echo the recipients
+  for name in recipients.valid
+    let name = s:GPGIDToName(name)
+    echo name
+  endfor
+
+  " echo the unknown recipients
+  echohl GPGWarning
+  for name in recipients.unknown
+    let name = "!" . name
+    echo name
+  endfor
+  echohl None
+
+  " check if there is any known recipient
+  if empty(recipients.valid)
+    echohl GPGError
+    echom 'There are no known recipients!'
+    echohl None
+  endif
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewRecipients()")
+endfunction
+
+" Function: s:GPGEditRecipients() {{{2
+"
+" create a scratch buffer with all recipients to add/remove recipients
+"
+function s:GPGEditRecipients()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditRecipients()")
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()")
+    return
+  endif
+
+  " only do this if it isn't already a GPGRecipients_* buffer
+  if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0)
+
+    " save buffer name
+    let buffername = bufname("%")
+    let editbuffername = "GPGRecipients_" . buffername
+
+    " check if this buffer exists
+    if (!bufexists(editbuffername))
+      " create scratch buffer
+      execute 'silent! split ' . fnameescape(editbuffername)
+
+      " add a autocommand to regenerate the recipients after a write
+      autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
+    else
+      if (bufwinnr(editbuffername) >= 0)
+        " switch to scratch buffer window
+        execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
+      else
+        " split scratch buffer window
+        execute 'silent! sbuffer ' . fnameescape(editbuffername)
+
+        " add a autocommand to regenerate the recipients after a write
+        autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
+      endif
+
+      " empty the buffer
+      silent %delete
+    endif
+
+    " Mark the buffer as a scratch buffer
+    setlocal buftype=acwrite
+    setlocal bufhidden=hide
+    setlocal noswapfile
+    setlocal nowrap
+    setlocal nobuflisted
+    setlocal nonumber
+
+    " so we know for which other buffer this edit buffer is
+    let b:GPGCorrespondingTo = buffername
+
+    " put some comments to the scratch buffer
+    silent put ='GPG: ----------------------------------------------------------------------'
+    silent put ='GPG: Please edit the list of recipients, one recipient per line.'
+    silent put ='GPG: Unknown recipients have a prepended \"!\".'
+    silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically.'
+    silent put ='GPG: Data after recipients between and including \"(\" and \")\" is ignored.'
+    silent put ='GPG: Closing this buffer commits changes.'
+    silent put ='GPG: ----------------------------------------------------------------------'
+
+    " get the recipients
+    let recipients = s:GPGCheckRecipients(getbufvar(b:GPGCorrespondingTo, "GPGRecipients"))
+
+    " if there are no known or unknown recipients, use the default ones
+    if (empty(recipients.valid) && empty(recipients.unknown))
+      if (type(g:GPGDefaultRecipients) == type([]))
+        let recipients = s:GPGCheckRecipients(g:GPGDefaultRecipients)
+      else
+        echohl GPGWarning
+        echom "g:GPGDefaultRecipients is not a Vim list, please correct this in your vimrc!"
+        echohl None
+      endif
+    endif
+
+    " put the recipients in the scratch buffer
+    for name in recipients.valid
+      let name = s:GPGIDToName(name)
+      silent put =name
+    endfor
+
+    " put the unknown recipients in the scratch buffer
+    let syntaxPattern = ''
+    if !empty(recipients.unknown)
+      let flaggedNames = map(recipients.unknown, '"!".v:val')
+      call append('$', flaggedNames)
+      let syntaxPattern = '\(' . join(flaggedNames, '\|') . '\)'
+    endif
+
+    for line in g:GPGPossibleRecipients
+        silent put ='GPG: '.line
+    endfor
+
+    " define highlight
+    if (has("syntax") && exists("g:syntax_on"))
+      highlight clear GPGUnknownRecipient
+      if !empty(syntaxPattern)
+        execute 'syntax match GPGUnknownRecipient    "' . syntaxPattern . '"'
+        highlight link GPGUnknownRecipient  GPGHighlightUnknownRecipient
+      endif
+
+      syntax match GPGComment "^GPG:.*$"
+      execute 'syntax match GPGComment "' . s:GPGMagicString . '.*$"'
+      highlight clear GPGComment
+      highlight link GPGComment Comment
+    endif
+
+    " delete the empty first line
+    silent 1delete
+
+    " jump to the first recipient
+    silent $
+
+  endif
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()")
+endfunction
+
+" Function: s:GPGFinishRecipientsBuffer() {{{2
+"
+" create a new recipient list from RecipientsBuffer
+"
+function s:GPGFinishRecipientsBuffer()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishRecipientsBuffer()")
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()")
+    return
+  endif
+
+  " go to buffer before doing work
+  if (bufnr("%") != expand("<abuf>"))
+    " switch to scratch buffer window
+    execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
+  endif
+
+  " delete the autocommand
+  autocmd! * <buffer>
+
+  " get the recipients from the scratch buffer
+  let recipients = []
+  let lines = getline(1,"$")
+  for recipient in lines
+    let matches = matchlist(recipient, '^\(.\{-}\)\%(' . s:GPGMagicString . '(ID:\s\+\(' . s:keyPattern . '\)\s\+.*\)\=$')
+
+    let recipient = matches[2] ? matches[2] : matches[1]
+
+    " delete all spaces at beginning and end of the recipient
+    " also delete a '!' at the beginning of the recipient
+    let recipient = substitute(recipient, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
+
+    " delete comment lines
+    let recipient = substitute(recipient, "^GPG:.*$", "", "")
+
+    " only do this if the line is not empty
+    if !empty(recipient)
+      let gpgid = s:GPGNameToID(recipient)
+      if !empty(gpgid)
+        if (match(recipients, gpgid) < 0)
+          let recipients += [gpgid]
+        endif
+      else
+        if (match(recipients, recipient) < 0)
+          let recipients += [recipient]
+          echohl GPGWarning
+          echom "The recipient \"" . recipient . "\" is not in your public keyring!"
+          echohl None
+        endif
+      endif
+    endif
+  endfor
+
+  " write back the new recipient list to the corresponding buffer and mark it
+  " as modified. Buffer is now for sure an encrypted buffer.
+  call setbufvar(b:GPGCorrespondingTo, "GPGRecipients", recipients)
+  call setbufvar(b:GPGCorrespondingTo, "&mod", 1)
+  call setbufvar(b:GPGCorrespondingTo, "GPGEncrypted", 1)
+
+  " check if there is any known recipient
+  if empty(recipients)
+    echohl GPGError
+    echom 'There are no known recipients!'
+    echohl None
+  endif
+
+  " reset modified flag
+  setl nomodified
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()")
+endfunction
+
+" Function: s:GPGViewOptions() {{{2
+"
+" echo the recipients
+"
+function s:GPGViewOptions()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewOptions()")
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()")
+    return
+  endif
+
+  if (exists("b:GPGOptions"))
+    echo 'This file has following options:'
+    " echo the options
+    for option in b:GPGOptions
+      echo option
+    endfor
+  endif
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()")
+endfunction
+
+" Function: s:GPGEditOptions() {{{2
+"
+" create a scratch buffer with all recipients to add/remove recipients
+"
+function s:GPGEditOptions()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditOptions()")
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()")
+    return
+  endif
+
+  " only do this if it isn't already a GPGOptions_* buffer
+  if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0)
+
+    " save buffer name
+    let buffername = bufname("%")
+    let editbuffername = "GPGOptions_" . buffername
+
+    " check if this buffer exists
+    if (!bufexists(editbuffername))
+      " create scratch buffer
+      execute 'silent! split ' . fnameescape(editbuffername)
+
+      " add a autocommand to regenerate the options after a write
+      autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
+    else
+      if (bufwinnr(editbuffername) >= 0)
+        " switch to scratch buffer window
+        execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
+      else
+        " split scratch buffer window
+        execute 'silent! sbuffer ' . fnameescape(editbuffername)
+
+        " add a autocommand to regenerate the options after a write
+        autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
+      endif
+
+      " empty the buffer
+      silent %delete
+    endif
+
+    " Mark the buffer as a scratch buffer
+    setlocal buftype=nofile
+    setlocal noswapfile
+    setlocal nowrap
+    setlocal nobuflisted
+    setlocal nonumber
+
+    " so we know for which other buffer this edit buffer is
+    let b:GPGCorrespondingTo = buffername
+
+    " put some comments to the scratch buffer
+    silent put ='GPG: ----------------------------------------------------------------------'
+    silent put ='GPG: THERE IS NO CHECK OF THE ENTERED OPTIONS!'
+    silent put ='GPG: YOU NEED TO KNOW WHAT YOU ARE DOING!'
+    silent put ='GPG: IF IN DOUBT, QUICKLY EXIT USING :x OR :bd.'
+    silent put ='GPG: Please edit the list of options, one option per line.'
+    silent put ='GPG: Please refer to the gpg documentation for valid options.'
+    silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically.'
+    silent put ='GPG: Closing this buffer commits changes.'
+    silent put ='GPG: ----------------------------------------------------------------------'
+
+    " put the options in the scratch buffer
+    let options = getbufvar(b:GPGCorrespondingTo, "GPGOptions")
+
+    for option in options
+      silent put =option
+    endfor
+
+    " delete the empty first line
+    silent 1delete
+
+    " jump to the first option
+    silent $
+
+    " define highlight
+    if (has("syntax") && exists("g:syntax_on"))
+      syntax match GPGComment "^GPG:.*$"
+      highlight clear GPGComment
+      highlight link GPGComment Comment
+    endif
+  endif
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()")
+endfunction
+
+" Function: s:GPGFinishOptionsBuffer() {{{2
+"
+" create a new option list from OptionsBuffer
+"
+function s:GPGFinishOptionsBuffer()
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishOptionsBuffer()")
+
+  " guard for unencrypted files
+  if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+    echohl GPGWarning
+    echom "File is not encrypted, all GPG functions disabled!"
+    echohl None
+    call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()")
+    return
+  endif
+
+  " go to buffer before doing work
+  if (bufnr("%") != expand("<abuf>"))
+    " switch to scratch buffer window
+    execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
+  endif
+
+  " clear options and unknownOptions
+  let options = []
+  let unknownOptions = []
+
+  " delete the autocommand
+  autocmd! * <buffer>
+
+  " get the options from the scratch buffer
+  let lines = getline(1, "$")
+  for option in lines
+    " delete all spaces at beginning and end of the option
+    " also delete a '!' at the beginning of the option
+    let option = substitute(option, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
+    " delete comment lines
+    let option = substitute(option, "^GPG:.*$", "", "")
+
+    " only do this if the line is not empty
+    if (!empty(option) && match(options, option) < 0)
+      let options += [option]
+    endif
+  endfor
+
+  " write back the new option list to the corresponding buffer and mark it
+  " as modified
+  call setbufvar(b:GPGCorrespondingTo, "GPGOptions", options)
+  call setbufvar(b:GPGCorrespondingTo, "&mod", 1)
+
+  " reset modified flag
+  setl nomodified
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()")
+endfunction
+
+" Function: s:GPGCheckRecipients(tocheck) {{{2
+"
+" check if recipients are known
+" Returns: dictionary of recipients, {'valid': [], 'unknown': []}
+"
+function s:GPGCheckRecipients(tocheck)
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGCheckRecipients()")
+
+  let recipients = {'valid': [], 'unknown': []}
+
+  if (type(a:tocheck) == type([]))
+    for recipient in a:tocheck
+      let gpgid = s:GPGNameToID(recipient)
+      if !empty(gpgid)
+        if (match(recipients.valid, gpgid) < 0)
+          call add(recipients.valid, gpgid)
+        endif
+      else
+        if (match(recipients.unknown, recipient) < 0)
+          call add(recipients.unknown, recipient)
+          echohl GPGWarning
+          echom "The recipient \"" . recipient . "\" is not in your public keyring!"
+          echohl None
+        endif
+      end
+    endfor
+  endif
+
+  call s:GPGDebug(2, "recipients are: " . string(recipients.valid))
+  call s:GPGDebug(2, "unknown recipients are: " . string(recipients.unknown))
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGCheckRecipients()")
+  return recipients
+endfunction
+
+" Function: s:GPGNameToID(name) {{{2
+"
+" find GPG key ID corresponding to a name
+" Returns: ID for the given name
+"
+function s:GPGNameToID(name)
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGNameToID()")
+
+  " ask gpg for the id for a name
+  let cmd = { 'level': 2 }
+  let cmd.args = '--quiet --with-colons --fixed-list-mode --list-keys ' . s:shellescape(a:name)
+  let output = s:GPGSystem(cmd)
+
+  " when called with "--with-colons" gpg encodes its output _ALWAYS_ as UTF-8,
+  " so convert it, if necessary
+  if (&encoding != "utf-8")
+    let output = iconv(output, "utf-8", &encoding)
+  endif
+  let lines = split(output, "\n")
+
+  " parse the output of gpg
+  let pubseen = 0
+  let counter = 0
+  let gpgids = []
+  let seen_keys = {}
+  let skip_key = 0
+  let has_strftime = exists('*strftime')
+  let choices = "The name \"" . a:name . "\" is ambiguous. Please select the correct key:\n"
+  for line in lines
+
+    let fields = split(line, ":")
+
+    " search for the next pub
+    if (fields[0] == "pub")
+      " check if this key has already been processed
+      if has_key(seen_keys, fields[4])
+        let skip_key = 1
+        continue
+      endif
+      let skip_key = 0
+      let seen_keys[fields[4]] = 1
+
+      " Ignore keys which are not usable for encryption
+      if fields[11] !~? 'e'
+        continue
+      endif
+
+      let identity = fields[4]
+      let gpgids += [identity]
+      if has_strftime
+        let choices = choices . counter . ": ID: 0x" . identity . " created at " . strftime("%c", fields[5]) . "\n"
+      else
+        let choices = choices . counter . ": ID: 0x" . identity . "\n"
+      endif
+      let counter = counter+1
+      let pubseen = 1
+    " search for the next uid
+    elseif (!skip_key && fields[0] == "uid")
+      let choices = choices . "   " . fields[9] . "\n"
+    endif
+
+  endfor
+
+  " counter > 1 means we have more than one results
+  let answer = 0
+  if (counter > 1)
+    let choices = choices . "Enter number: "
+    let answer = input(choices, "0")
+    while (answer == "")
+      let answer = input("Enter number: ", "0")
+    endwhile
+  endif
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGNameToID()")
+  return get(gpgids, answer, "")
+endfunction
+
+" Function: s:GPGIDToName(identity) {{{2
+"
+" find name corresponding to a GPG key ID
+" Returns: Name for the given ID
+"
+function s:GPGIDToName(identity)
+  call s:GPGDebug(3, ">>>>>>>> Entering s:GPGIDToName()")
+
+  " TODO is the encryption subkey really unique?
+
+  " ask gpg for the id for a name
+  let cmd = { 'level': 2 }
+  let cmd.args = '--quiet --with-colons --fixed-list-mode --list-keys ' . a:identity
+  let output = s:GPGSystem(cmd)
+
+  " when called with "--with-colons" gpg encodes its output _ALWAYS_ as UTF-8,
+  " so convert it, if necessary
+  if (&encoding != "utf-8")
+    let output = iconv(output, "utf-8", &encoding)
+  endif
+  let lines = split(output, "\n")
+
+  " parse the output of gpg
+  let pubseen = 0
+  let uid = ""
+  for line in lines
+    let fields = split(line, ":")
+
+    if !pubseen " search for the next pub
+      if (fields[0] == "pub")
+        " Ignore keys which are not usable for encryption
+        if fields[11] !~? 'e'
+          continue
+        endif
+
+        let pubseen = 1
+      endif
+    else " search for the next uid
+      if (fields[0] == "uid")
+        let pubseen = 0
+        if exists("*strftime")
+          let uid = fields[9] . s:GPGMagicString . "(ID: 0x" . a:identity . " created at " . strftime("%c", fields[5]) . ")"
+        else
+          let uid = fields[9] . s:GPGMagicString . "(ID: 0x" . a:identity . ")"
+        endif
+        break
+      endif
+    endif
+  endfor
+
+  call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGIDToName()")
+  return uid
+endfunction
+
+" Function: s:GPGPreCmd() {{{2
+"
+" Setup the environment for running the gpg command
+"
+function s:GPGPreCmd()
+  let &shellredir = s:shellredir
+  let &shell = s:shell
+  let &shelltemp = s:shelltemp
+  " Force C locale so GPG output is consistent
+  let s:messages = v:lang
+  language messages C
+endfunction
+
+
+" Function: s:GPGPostCmd() {{{2
+"
+" Restore the user's environment after running the gpg command
+"
+function s:GPGPostCmd()
+  let &shellredir = s:shellredirsave
+  let &shell = s:shellsave
+  let &shelltemp = s:shelltempsave
+  execute 'language messages' s:messages
+  " Workaround a bug in the interaction between console vim and
+  " pinentry-curses by forcing Vim to re-detect and setup its terminal
+  " settings
+  let &term = &term
+  silent doautocmd TermChanged
+endfunction
+
+" Function: s:GPGSystem(dict) {{{2
+"
+" run g:GPGCommand using system(), logging the commandline and output.  This
+" uses temp files (regardless of how 'shelltemp' is set) to hold the output of
+" the command, so it must not be used for sensitive commands.
+" Recognized keys are:
+" level - Debug level at which the commandline and output will be logged
+" args - Arguments to be given to g:GPGCommand
+"
+" Returns: command output
+"
+function s:GPGSystem(dict)
+  let commandline = s:GPGCommand
+  if (!empty(g:GPGHomedir))
+    let commandline .= ' --homedir ' . s:shellescape(g:GPGHomedir)
+  endif
+  let commandline .= ' ' . a:dict.args
+  let commandline .= ' ' . s:stderrredirnull
+  call s:GPGDebug(a:dict.level, "command: ". commandline)
+
+  call s:GPGPreCmd()
+  let output = system(commandline)
+  call s:GPGPostCmd()
+
+  call s:GPGDebug(a:dict.level, "rc: ". v:shell_error)
+  call s:GPGDebug(a:dict.level, "output: ". output)
+  return output
+endfunction
+
+" Function: s:GPGExecute(dict) {{{2
+"
+" run g:GPGCommand using :execute, logging the commandline
+" Recognized keys are:
+" level - Debug level at which the commandline will be logged
+" args - Arguments to be given to g:GPGCommand
+" ex - Ex command which will be :executed
+" redirect - Shell redirect to use, if needed
+"
+function s:GPGExecute(dict)
+  let commandline = printf('%s%s', a:dict.ex, s:GPGCommand)
+  if (!empty(g:GPGHomedir))
+    let commandline .= ' --homedir ' . s:shellescape(g:GPGHomedir, 1)
+  endif
+  let commandline .= ' ' . a:dict.args
+  if (has_key(a:dict, 'redirect'))
+    let commandline .= ' ' . a:dict.redirect
+  endif
+  let commandline .= ' ' . s:stderrredirnull
+  call s:GPGDebug(a:dict.level, "command: " . commandline)
+
+  call s:GPGPreCmd()
+  execute commandline
+  call s:GPGPostCmd()
+
+  call s:GPGDebug(a:dict.level, "rc: ". v:shell_error)
+endfunction
+
+" Function: s:GPGDebug(level, text) {{{2
+"
+" output debug message, if this message has high enough importance
+" only define function if GPGDebugLevel set at all
+"
+function s:GPGDebug(level, text)
+  if exists("g:GPGDebugLevel") && g:GPGDebugLevel >= a:level
+    if exists("g:GPGDebugLog")
+      execute "redir >> " . g:GPGDebugLog
+      silent echom "GnuPG: " . a:text
+      redir END
+    else
+      echom "GnuPG: " . a:text
+    endif
+  endif
+endfunction
+
+" Section: Commands {{{1
+
+command! GPGViewRecipients call s:GPGViewRecipients()
+command! GPGEditRecipients call s:GPGEditRecipients()
+command! GPGViewOptions call s:GPGViewOptions()
+command! GPGEditOptions call s:GPGEditOptions()
+
+" Section: Menu {{{1
+
+if (has("menu"))
+  amenu <silent> Plugin.GnuPG.View\ Recipients :GPGViewRecipients<CR>
+  amenu <silent> Plugin.GnuPG.Edit\ Recipients :GPGEditRecipients<CR>
+  amenu <silent> Plugin.GnuPG.View\ Options :GPGViewOptions<CR>
+  amenu <silent> Plugin.GnuPG.Edit\ Options :GPGEditOptions<CR>
+endif
+
+" vim600: set foldmethod=marker foldlevel=0 :
diff --git a/vim/vim/plugin/matrix.vim b/vim/vim/plugin/matrix.vim
new file mode 100644 (file)
index 0000000..9ed838d
--- /dev/null
@@ -0,0 +1,325 @@
+" matrix.vim - Don Yang (uguu.org)
+"
+" Matrix screensaver for VIM.
+"
+"Usage:
+" After loading the script, use :Matrix to start.
+" Press any key a few times to exit.
+"
+" You will need to edit s:mindelay and s:maxdelay below to match your
+" machine speed and window size.
+"
+"Known Issues:
+" Sometimes you need to press keys a few times to exit instead of just
+" once.  Press and hold is another way to go... feels like getchar is
+" checking for keypress state instead of keystroke availability.
+"
+" If the window is too small, script will not run.  If the window is
+" resized and become too small (less than 8 rows or 10 columns) after
+" the script started, script will abort and *buffers may be lost*, so
+" don't do that.  Resizing the window to most other sizes will be fine.
+"
+" Doesn't work if multiple windows exist before script started.  In
+" that case the script will abort with error message.
+"
+" If the current buffer is modified, some error messages will appear
+" before the script starts, and an extra window is left behind after
+" the script exits.  Workaround: save your buffers first.
+"
+"Other Info:
+" Inspired by cmatrix...
+" Didn't feel inspired enough to start using pico/nano, of course ^_^;
+"
+" 05/13/08 - disable cursorline, cursorcolumn and spell
+"            (thanks to Diederick Niehorster for the suggestion).
+" 12/21/06 - multiwindow support by S. Lockwood-Childs.
+" 10/03/05 - added silent! to cursor positioning code to stop drawing
+"            numbers during animation (thanks to David Eggum for the
+"            suggestion).
+" 10/02/05 - disable showmatch
+" 03/16/05 - make new buffer modifiable before running
+" 01/27/05 - added sleep to consume less CPU
+"            removed frame counter
+" 01/26/05 - initial version
+
+
+" Speed range, must be positive.  Lower delay = faster.
+let s:mindelay = 1
+let s:maxdelay = 5
+
+" Session file for preserving original window layout
+let s:session_file = tempname()
+
+
+function! s:Rand()
+   let b:seed = b:seed * 22695477 + 1
+   if b:seed < 0
+      return -b:seed
+   endif
+   return b:seed
+endfunction
+
+function! s:CreateObject(i)
+   while 1
+      let b:x{a:i} = s:Rand() % b:columns
+      if b:reserve{b:x{a:i}} > 4
+         break
+      endif
+   endwhile
+   let b:y{a:i} = 1
+   let b:t{a:i} = s:Rand() % b:s{b:x{a:i}}
+   let b:head{a:i} = s:Rand() % 4
+   let b:len{a:i} = s:Rand() % b:h + 3
+   let b:reserve{b:x{a:i}} = 1 - b:len{a:i}
+endfunction
+
+function! s:DrawObject(i)
+   let x = b:x{a:i} * 2 + 1
+   let y = b:y{a:i}
+
+   " Draw head
+   if y <= b:h
+      if b:head{a:i}
+         silent! exec 'norm! :' . y . nr2char(13) . x . '|R' . b:d[s:Rand()%b:dl] . '_' . nr2char(27)
+         if y > 1
+            silent! exec 'norm! kR' . ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
+         endif
+      else
+         let a = ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
+         silent! exec 'norm! :'. y . nr2char(13) . x . '|R' . b:d[s:Rand() % b:dl] . a
+      endif
+   else
+      if b:head{a:i} && y == b:h + 1
+         silent! exec 'norm! :' . b:h . nr2char(13) . (x + 1) . '|R' . ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
+      endif
+   endif
+
+   " Draw tail
+   let y = y - b:len{a:i}
+   if 1 <= y && y <= b:h
+      silent! exec 'norm! :'. y . nr2char(13) . x . '|R  ' . nr2char(27)
+   endif
+   let b:reserve{b:x{a:i}} = y
+endfunction
+
+function! s:Animate()
+   let i = 0
+
+   while i < b:objcount
+      " Animate object
+      if b:t{i} <= 0
+         if b:y{i} - b:len{i} <= b:h
+            " Draw
+            call s:DrawObject(i)
+            let b:t{i} = b:s{b:x{i}}
+            let b:y{i} = b:y{i} + 1
+         else
+            " Regenerate
+            call s:CreateObject(i)
+         endif
+      endif
+
+      let b:t{i} = b:t{i} - 1
+      let i = i + 1
+   endwhile
+   redraw
+   if getchar(1)
+      let b:run = 0
+   endif
+   sleep 20m
+endfunction
+
+function! s:Reset()
+   " Clear screen
+   let b:w = winwidth(0)
+   let b:h = winheight(0)
+   exec 'norm! gg"_dG' . b:h . 'O' . nr2char(27) . 'gg'
+   redraw
+   if b:w < 10 || b:h < 8
+      let b:run = 0
+      return
+   endif
+
+   " Set number of columns.  This is rounded down due to line wrapping
+   " at the last column if the screen width is even.  So you end up
+   " seeing the cursor blinking a lot at the right side of the screen.
+   " Alternatively, ':set rl' before running the script to have it
+   " blink on the left side.
+   let b:columns = (b:w - 1) / 2
+
+   " Initialize columns.
+   let i = 0
+   while i < b:columns
+      " Set delay time.  Each column gets the same delay time.
+      let b:s{i} = s:Rand() % (s:maxdelay - s:mindelay) + s:mindelay
+
+      " Unreserve column
+      let b:reserve{i} = b:h
+      let i = i + 1
+   endwhile
+
+   " Initialize objects
+   let b:objcount = b:columns - 2
+   let i = 0
+   while i < b:objcount
+      call s:CreateObject(i)
+      let i = i + 1
+   endwhile
+endfunction
+
+function! s:Init()
+   " Create new buffer and hide the existing buffers.  Hiding the
+   " existing buffers without switching to a new buffer preserves
+   " undo history.
+   exec 'mksession! ' . s:session_file
+   let s:num_orig_win = winnr("$")
+
+   " move to top window, so created window will become window 1,
+   " then attempt to create new window
+   1 wincmd w
+   silent! new
+
+   " check that there really is an additional window
+   if winnr("$") != s:num_orig_win + 1
+      return 1
+   endif
+   let s:newbuf = bufnr('%')
+
+   " close all but window 1, which is the new window
+   only
+
+   setl bh=delete bt=nofile ma nolist nonu noro noswf tw=0 nowrap
+
+   " Set GUI options
+   if has('gui')
+      let s:o_gcr = &gcr
+      let s:o_go = &go
+      set gcr=a:ver1-blinkon0 go=
+   endif
+   if has('cmdline_info')
+      let s:o_ru = &ru
+      let s:o_sc = &sc
+      set noru nosc
+   endif
+   if has('title')
+      let s:o_ts = &titlestring
+      exec 'set titlestring=\ '
+   endif
+   if v:version >= 700
+      let s:o_spell = &spell
+      let s:o_cul = &cul
+      let s:o_cuc = &cuc
+      set nospell nocul nocuc
+   endif
+   let s:o_ch = &ch
+   let s:o_ls = &ls
+   let s:o_lz = &lz
+   let s:o_siso = &siso
+   let s:o_sm = &sm
+   let s:o_smd = &smd
+   let s:o_so = &so
+   let s:o_ve = &ve
+   set ch=1 ls=0 lz nosm nosmd siso=0 so=0 ve=all
+
+   " Initialize PRNG
+   let b:seed = localtime()
+   let b:run = 1
+
+   " Clear screen and initialize objects
+   call s:Reset()
+
+   " Set colors.  Output looks better if your color scheme has black
+   " background.  I would rather not have the script change the
+   " current color scheme since there is no good way to restore them
+   " afterwards.
+   hi MatrixHidden ctermfg=Black ctermbg=Black guifg=#000000 guibg=#000000
+   hi MatrixNormal ctermfg=DarkGreen ctermbg=Black guifg=#008000 guibg=#000000
+   hi MatrixBold ctermfg=LightGreen ctermbg=Black guifg=#00ff00 guibg=#000000
+   hi MatrixHead ctermfg=White ctermbg=Black guifg=#ffffff guibg=#000000
+   sy match MatrixNormal /^.*/ contains=MatrixHidden
+   sy match MatrixHidden contained /.`/ contains=MatrixBold
+   sy match MatrixHidden contained /._/ contains=MatrixHead
+   sy match MatrixBold contained /.\(`\)\@=/
+   sy match MatrixHead contained /.\(_\)\@=/
+
+   " Create random char dictionary
+   let b:d = ''
+   let i = 33
+   while i < 127
+      if i != 95 && i != 96
+         let b:d = b:d . nr2char(i)
+      endif
+      let i = i + 1
+   endwhile
+   let b:dl = strlen(b:d)
+   return 0
+endfunction
+
+function! s:Cleanup()
+   " Restore options
+   if has('gui')
+      let &gcr = s:o_gcr
+      let &go = s:o_go
+      unlet s:o_gcr s:o_go
+   endif
+   if has('cmdline_info')
+      let &ru = s:o_ru
+      let &sc = s:o_sc
+      unlet s:o_ru s:o_sc
+   endif
+   if has('title')
+      let &titlestring = s:o_ts
+      unlet s:o_ts
+   endif
+   if v:version >= 700
+      let &spell = s:o_spell
+      let &cul = s:o_cul
+      let &cuc = s:o_cuc
+      unlet s:o_cul s:o_cuc
+   endif
+   let &ch = s:o_ch
+   let &ls = s:o_ls
+   let &lz = s:o_lz
+   let &siso = s:o_siso
+   let &sm = s:o_sm
+   let &smd = s:o_smd
+   let &so = s:o_so
+   let &ve = s:o_ve
+   unlet s:o_ch s:o_ls s:o_lz s:o_siso s:o_sm s:o_smd s:o_so s:o_ve
+
+   " Restore old buffers
+   exec 'source ' . s:session_file
+   exec 'bwipe ' . s:newbuf
+   unlet s:newbuf
+
+   " Clear keystroke
+   let c = getchar(0)
+endfunction
+
+function! Matrix()
+   if s:Init()
+      echohl ErrorMsg
+      echon 'Can not create window'
+      echohl None
+      return
+   endif
+
+   while b:run
+      if b:w != winwidth(0) || b:h != winheight(0)
+         call s:Reset()
+      else
+         call s:Animate()
+      endif
+   endwhile
+
+   call s:Cleanup()
+endfunction
+
+
+if !has('virtualedit') || !has('windows') || !has('syntax')
+   echohl ErrorMsg
+   echon 'Not enough features, need at least +virtualedit, +windows and +syntax'
+   echohl None
+else
+   command! Matrix call Matrix()
+endif
diff --git a/vim/vim/plugin/securemodelines.vim b/vim/vim/plugin/securemodelines.vim
new file mode 100644 (file)
index 0000000..2893b48
--- /dev/null
@@ -0,0 +1,153 @@
+" vim: set sw=4 sts=4 et ft=vim :
+" Script:           securemodelines.vim
+" Version:          10d6c6b52fcdd12f3ba457126f66fee4ccceec04
+" Author:           Ciaran McCreesh <ciaran.mccreesh at googlemail.com>
+" Homepage:         http://github.com/ciaranm/securemodelines
+" Requires:         Vim 7
+" License:          Redistribute under the same terms as Vim itself
+" Purpose:          A secure alternative to modelines
+
+if &compatible || v:version < 700 || exists('g:loaded_securemodelines')
+    finish
+endif
+let g:loaded_securemodelines = 1
+
+if (! exists("g:secure_modelines_allowed_items"))
+    let g:secure_modelines_allowed_items = [
+                \ "textwidth",   "tw",
+                \ "softtabstop", "sts",
+                \ "tabstop",     "ts",
+                \ "shiftwidth",  "sw",
+                \ "expandtab",   "et",   "noexpandtab", "noet",
+                \ "filetype",    "ft",
+                \ "foldmethod",  "fdm",
+                \ "readonly",    "ro",   "noreadonly", "noro",
+                \ "rightleft",   "rl",   "norightleft", "norl",
+                \ "cindent",     "cin",  "nocindent", "nocin",
+                \ "smartindent", "si",   "nosmartindent", "nosi",
+                \ "autoindent",  "ai",   "noautoindent", "noai",
+                \ "spell",
+                \ "spelllang"
+                \ ]
+endif
+
+if (! exists("g:secure_modelines_verbose"))
+    let g:secure_modelines_verbose = 0
+endif
+
+if (! exists("g:secure_modelines_modelines"))
+    let g:secure_modelines_modelines=5
+endif
+
+if (! exists("g:secure_modelines_leave_modeline"))
+    if &modeline
+        set nomodeline
+        if g:secure_modelines_verbose
+            echohl WarningMsg
+            echo "Forcibly disabling internal modelines for securemodelines.vim"
+            echohl None
+        endif
+    endif
+endif
+
+fun! <SID>IsInList(list, i) abort
+    for l:item in a:list
+        if a:i == l:item
+            return 1
+        endif
+    endfor
+    return 0
+endfun
+
+fun! <SID>DoOne(item) abort
+    let l:matches = matchlist(a:item, '^\([a-z]\+\)\%([-+^]\?=[a-zA-Z0-9_\-.]\+\)\?$')
+    if len(l:matches) > 0
+        if <SID>IsInList(g:secure_modelines_allowed_items, l:matches[1])
+            exec "setlocal " . a:item
+        elseif g:secure_modelines_verbose
+            echohl WarningMsg
+            echo "Ignoring '" . a:item . "' in modeline"
+            echohl None
+        endif
+    endif
+endfun
+
+fun! <SID>DoNoSetModeline(line) abort
+    for l:item in split(a:line, '[ \t:]')
+        call <SID>DoOne(l:item)
+    endfor
+endfun
+
+fun! <SID>DoSetModeline(line) abort
+    for l:item in split(a:line)
+        call <SID>DoOne(l:item)
+    endfor
+endfun
+
+fun! <SID>CheckVersion(op, ver) abort
+    if a:op == "="
+        return v:version != a:ver
+    elseif a:op == "<"
+        return v:version < a:ver
+    elseif a:op == ">"
+        return v:version >= a:ver
+    else
+        return 0
+    endif
+endfun
+
+fun! <SID>DoModeline(line) abort
+    let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\s*\%(set\s\+\)\?\([^:]\+\):\S\@!')
+    if len(l:matches) > 0
+        let l:operator = ">"
+        if len(l:matches[1]) > 0
+            let l:operator = l:matches[1]
+        endif
+        if len(l:matches[2]) > 0
+            if <SID>CheckVersion(l:operator, l:matches[2]) ? 0 : 1
+                return
+            endif
+        endif
+        return <SID>DoSetModeline(l:matches[3])
+    endif
+
+    let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\(.\+\)')
+    if len(l:matches) > 0
+        let l:operator = ">"
+        if len(l:matches[1]) > 0
+            let l:operator = l:matches[1]
+        endif
+        if len(l:matches[2]) > 0
+            if <SID>CheckVersion(l:operator, l:matches[2]) ? 0 : 1
+                return
+            endif
+        endif
+        return <SID>DoNoSetModeline(l:matches[3])
+    endif
+endfun
+
+fun! <SID>DoModelines() abort
+    if line("$") > g:secure_modelines_modelines
+        let l:lines={ }
+        call map(filter(getline(1, g:secure_modelines_modelines) +
+                    \ getline(line("$") - g:secure_modelines_modelines, "$"),
+                    \ 'v:val =~ ":"'), 'extend(l:lines, { v:val : 0 } )')
+        for l:line in keys(l:lines)
+            call <SID>DoModeline(l:line)
+        endfor
+    else
+        for l:line in getline(1, "$")
+            call <SID>DoModeline(l:line)
+        endfor
+    endif
+endfun
+
+fun! SecureModelines_DoModelines() abort
+    call <SID>DoModelines()
+endfun
+
+aug SecureModeLines
+    au!
+    au BufRead,StdinReadPost * :call <SID>DoModelines()
+aug END
+
diff --git a/vim/vim/syntax/asciidoc.vim b/vim/vim/syntax/asciidoc.vim
new file mode 100644 (file)
index 0000000..d63a095
--- /dev/null
@@ -0,0 +1,173 @@
+" Vim syntax file
+" Language:     AsciiDoc
+" Author:       Stuart Rackham <srackham@gmail.com> (inspired by Felix
+"               Obenhuber's original asciidoc.vim script).
+" URL:          http://www.methods.co.nz/asciidoc/
+" Licence:      GPL (http://www.gnu.org)
+" Remarks:      Vim 6 or greater
+" Limitations:  See 'Appendix E: Vim Syntax Highlighter' in the AsciiDoc 'User
+"               Guide'.
+
+if exists("b:current_syntax")
+  finish
+endif
+
+syn clear
+syn sync fromstart
+syn sync linebreaks=1
+
+" Run :help syn-priority to review syntax matching priority.
+syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED
+syn match asciidocBackslash /\\/
+syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/
+syn match asciidocCallout /\\\@<!<\d\{1,2}>/
+syn match asciidocListBlockDelimiter /^--$/
+syn match asciidocLineBreak /[ \t]+$/
+syn match asciidocRuler /^'\{3,}$/
+syn match asciidocPagebreak /^<\{3,}$/
+syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/
+syn region asciidocLiteralParagraph start=/\(\%^\|\_^\n\)\@<=\s\+\S\+/ end=/\(^\(+\|--\)\?\s*$\)\@=/ contains=asciidocToDo
+syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/
+syn match asciidocEmail /[\\.:]\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/
+syn match asciidocAttributeRef /\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}/
+
+" As a damage control measure quoted patterns always terminate at a blank
+" line (see 'Limitations' above).
+syn match asciidocQuotedAttributeList /\\\@<!\[[a-zA-Z0-9_-][a-zA-Z0-9 _-]*\][+_'`#*]\@=/
+syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/ contains=asciidocEntityRef
+syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\)/
+syn match asciidocQuotedUnconstrainedMonospaced /[\\+]\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedUnconstrainedEmphasized /\\\@<!__\S\_.\{-}\(__\|\n\s*\n\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedBold /\(^\|[| \t([.,=\]]\)\@<=\*\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(\*\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+syn match asciidocQuotedUnconstrainedBold /\\\@<!\*\*\S\_.\{-}\(\*\*\|\n\s*\n\)/ contains=asciidocEntityRef
+
+" Don't allow ` in single quoted (a kludge to stop confusion with `monospaced`).
+syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\([^`]\|\n\(\s*\n\)\@!\)\{-}[^` \t]\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+
+syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=\]]\)\@<=``\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(''\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
+
+syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
+syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
+
+syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/
+
+syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/
+syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef
+syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE
+syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash
+syn match asciidocTwoLineTitle /^[^. +/].*[^.]\n[-=~^+]\{2,}$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocTitleUnderline
+
+syn match asciidocAttributeList /^\[[^[ \t].*\]$/
+syn match asciidocQuoteBlockDelimiter /^_\{4,}$/
+syn match asciidocExampleBlockDelimiter /^=\{4,}$/
+syn match asciidocSidebarDelimiter /^*\{4,}$/
+
+" See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region
+" contents from highlighting.
+syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained
+syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL
+syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained
+syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL
+
+syn match asciidocListContinuation /^+$/
+syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
+syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
+syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo
+syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$"
+
+" Allowing leading \w characters in the filter delimiter is to accomodate
+" the pre version 8.2.7 syntax and may be removed in future releases.
+syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/
+
+syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@<!<<"\{-}\(\w\|-\|_\|:\|\.\)\+"\?,\?/ end=/\(>>\)\|^$/ contains=asciidocQuoted.* keepend
+syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{2}\(\w\|-\|_\|:\|\.\)\+,\?/ end=/\]\{2}/ keepend
+syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{3}\(\w\|-\|_\|:\|\.\)\+/ end=/\]\{3}/ keepend
+syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/[\\0-9a-zA-Z]\@<!\w\(\w\|-\)*:\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
+" Highlight macro that starts with an attribute reference (a common idiom).
+syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/\(\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}\)\@<=\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
+syn region asciidocMacroAttributes matchgroup=asciidocIndexTerm start=/\\\@<!(\{2,3}/ end=/)\{2,3}/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
+
+syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo
+
+syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline
+
+" Lists.
+syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/
+syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/
+syn region asciidocListLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocToDo keepend
+" DEPRECATED: Horizontal label.
+syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend
+" Starts with any of the above.
+syn region asciidocList start=/^\s*\(-\|\*\{1,5}\)\s/ start=/^\s*\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\s\+/ start=/.\+\(:\{2,4}\|;;\)$/ end=/\(^[=*]\{4,}$\)\@=/ end=/\(^+\?\s*$\)\@=/ contains=asciidocList.\+,asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocCommentLine,asciidocAttributeList,asciidocToDo
+
+highlight link asciidocAdmonition Special
+highlight link asciidocAnchorMacro Macro
+highlight link asciidocAttributeEntry Special
+highlight link asciidocAttributeList Special
+highlight link asciidocAttributeMacro Macro
+highlight link asciidocAttributeRef Special
+highlight link asciidocBackslash Special
+highlight link asciidocBlockTitle Title
+highlight link asciidocCallout Label
+highlight link asciidocCommentBlock Comment
+highlight link asciidocCommentLine Comment
+highlight link asciidocDoubleDollarPassthrough Special
+highlight link asciidocEmail Macro
+highlight link asciidocEntityRef Special
+highlight link asciidocExampleBlockDelimiter Type
+highlight link asciidocFilterBlock Type
+highlight link asciidocHLabel Label
+highlight link asciidocIdMarker Special
+highlight link asciidocIndexTerm Macro
+highlight link asciidocLineBreak Special
+highlight link asciidocListBlockDelimiter Label
+highlight link asciidocListBullet Label
+highlight link asciidocListContinuation Label
+highlight link asciidocListingBlock Identifier
+highlight link asciidocListLabel Label
+highlight link asciidocListNumber Label
+highlight link asciidocLiteralBlock Identifier
+highlight link asciidocLiteralParagraph Identifier
+highlight link asciidocMacroAttributes Label
+highlight link asciidocMacro Macro
+highlight link asciidocOneLineTitle Title
+highlight link asciidocPagebreak Type
+highlight link asciidocPassthroughBlock Identifier
+highlight link asciidocQuoteBlockDelimiter Type
+highlight link asciidocQuotedAttributeList Special
+highlight link asciidocQuotedBold Special
+highlight link asciidocQuotedDoubleQuoted Label
+highlight link asciidocQuotedEmphasized2 Type
+highlight link asciidocQuotedEmphasized Type
+highlight link asciidocQuotedMonospaced2 Identifier
+highlight link asciidocQuotedMonospaced Identifier
+highlight link asciidocQuotedSingleQuoted Label
+highlight link asciidocQuotedSubscript Type
+highlight link asciidocQuotedSuperscript Type
+highlight link asciidocQuotedUnconstrainedBold Special
+highlight link asciidocQuotedUnconstrainedEmphasized Type
+highlight link asciidocQuotedUnconstrainedMonospaced Identifier
+highlight link asciidocRefMacro Macro
+highlight link asciidocRuler Type
+highlight link asciidocSidebarDelimiter Type
+highlight link asciidocTableBlock2 NONE
+highlight link asciidocTableBlock NONE
+highlight link asciidocTableDelimiter2 Label
+highlight link asciidocTableDelimiter Label
+highlight link asciidocTable_OLD Type
+highlight link asciidocTablePrefix2 Label
+highlight link asciidocTablePrefix Label
+highlight link asciidocToDo Todo
+highlight link asciidocTriplePlusPassthrough Special
+highlight link asciidocTwoLineTitle Title
+highlight link asciidocURL Macro
+let b:current_syntax = "asciidoc"
+
+" vim: wrap et sw=2 sts=2:
diff --git a/vim/vim/syntax/getmailrc.vim b/vim/vim/syntax/getmailrc.vim
new file mode 100644 (file)
index 0000000..541e22f
--- /dev/null
@@ -0,0 +1,130 @@
+" Vim syntax file
+" Language:    getmailrc - configuration file for getmail version 4
+" Maintainer:  Nikolai Nespor <nikolai.nespor@utanet.at>
+" URL:         http://www.unet.univie.ac.at/~a9600989/vim/getmailrc.vim
+" Last Change: 2005 02 22
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+" string, ints and comments
+syn match gmComment     /#.*$/
+syn match gmInt         /\<\d\+\>/
+syn region gmDbQuoteStr start=+"+ skip=+\\"+ end=+"+
+syn region gmQuoteStr   start=+'+ skip=+\\'+ end=+'+
+
+" booleans are case insensitive
+syn case ignore
+  syn keyword gmTrue 1 true yes on
+  syn keyword gmFalse 0 false no off
+syn case match
+
+syn match gmParam       /^\s*\w\+\s*=/ contains=gmKeywd
+syn match gmSection     /^\s*\[\(retriever\|destination\|options\)\]\s*$/
+syn match gmFilterSec   /^\s*\[filter-\w\+\]\s*$/
+
+syn keyword gmType type contained
+
+" retriever section
+"
+
+" retriever type
+syn match gmRetType /^\s*type\s*=\s*[a-zA-Z3]\+\s*$/ contains=gmRetTypes,gmType
+syn keyword gmRetTypes BrokenUIDLPOP3Retriver contained 
+syn keyword gmRetTypes SimplePOP3Retriever SimpleIMAPRetriever contained 
+syn keyword gmRetTypes SimplePOP3SSLRetriever SimpleIMAPSSLRetriever contained 
+syn keyword gmRetTypes MultidropPOP3Retriever MultidropPOP3SSLRetriever contained 
+syn keyword gmRetTypes MultidropSPDSRetriever MultidropIMAPRetriever contained 
+syn keyword gmRetTypes MultidropIMAPSSLRetriever contained 
+
+" common retriever options
+syn keyword gmKeywd password port server username contained 
+" POP3
+syn keyword gmKeywd use_apop contained 
+" IMAP
+syn keyword gmKeywd mailboxes move_on_delete contained 
+" SSL
+syn keyword gmKeywd certfile keyfile contained 
+" multidrop
+syn keyword gmKeywd envelope_recipient contained 
+" timeout
+syn keyword gmKeywd timeout contained 
+
+" destination section
+"
+
+" destination type
+syn match gmDestType /^\s*type\s*=\s*\(Maildir\|Mboxrd\|MDA_external\|MultiDestination\|MultiGuesser\|MultiSorter\|MDA_qmaillocal\)\s*$/ contains=gmDestTypes,gmType
+syn keyword gmDestTypes Maildir Mboxrd MDA_external MultiDestination contained 
+syn keyword gmDestTypes MultiGuesser MultiSorter MDA_qmaillocal contained 
+
+" Maildir, Mboxrd and MDA_external common options
+syn keyword gmKeywd path contained 
+" MDA_external
+syn keyword gmKeywd allow_root_commands arguments group contained 
+syn keyword gmKeywd unixfrom user contained 
+" MultiSorter
+syn keyword gmKeywd default locals contained 
+" MDA_qmaillocal plus allow_root_command, group and user from
+" MDA_external
+syn keyword gmKeywd conf-break defaultdelivery homedir contained 
+syn keyword gmKeywd localdomain localpart_translate qmaillocal contained 
+syn keyword gmKeywd strip_delivered_to contained 
+
+" option section
+"
+syn keyword gmKeywd delete delete_after delivered_to contained 
+syn keyword gmKeywd max_messages_per_session max_message_size contained 
+syn keyword gmKeywd message_log message_log_syslog read_all received contained 
+syn keyword gmKeywd verbose contained 
+
+" filter section
+"
+
+" filter type
+syn match gmFilterType /^\s*type\s*=\s*\(Filter_classifier\|Filter_external\|Filter_TMDA\)\s*$/ contains=gmFilterTypes,gmType
+syn keyword gmFilterTypes Filter_classifier Filter_external Filter_TMDA contained
+
+" filter options
+syn keyword gmKeywd allow_root_commands arguments exitcodes_drop contained 
+syn keyword gmKeywd exitcodes_keep group path unixfrom user contained 
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_getmail_syn_inits")
+  if version < 508
+    let did_getmail_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+  HiLink gmComment      Comment
+  HiLink gmInt          Identifier
+  HiLink gmDbQuoteStr   String
+  HiLink gmQuoteStr     String
+  
+  HiLink gmTrue         Identifier
+  HiLink gmFalse        Constant
+  
+  HiLink gmParam        Normal
+  HiLink gmSection      Statement
+  HiLink gmFilterSec    Statement
+
+  HiLink gmKeywd        Type
+  HiLink gmType         Type
+
+  HiLink gmRetTypes     PreProc
+  HiLink gmDestTypes    PreProc
+  HiLink gmFilterTypes  PreProc
+  delcommand HiLink
+endif
+
+let b:current_syntax = "getmail"
+
+" vim: ts=8
diff --git a/vim/vim/syntax/msmtp.vim b/vim/vim/syntax/msmtp.vim
new file mode 100644 (file)
index 0000000..1b0f8df
--- /dev/null
@@ -0,0 +1,52 @@
+" Vim syntax file
+" Language:     msmtp rc files
+" Maintainer:   Simon Ruderich <simon@ruderich.org>
+" Last Change:  2008-08-23
+" Filenames:    msmtprc
+" Version:      0.1
+
+
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+
+" Comments.
+syn match msmtpComment /#.*$/ contains=@Spell
+
+" General commands.
+syntax match msmtpOption /\<\(defaults\|account\|host\|port\|timeout\|protocol\|domain\)\>/
+" Authentication commands.
+syntax match msmtpOption /\<\(auth\|user\|password\|passwordeval\|ntlmdomain\)\>/
+" TLS commands.
+syntax match msmtpOption /\<\(tls\|tls_trust_file\|tls_crl_file\|tls_fingerprint\|tls_key_file\|tls_cert_file\|tls_certcheck\|tls_starttls\|tls_force_sslv3\|tls_min_dh_prime_bits\|tls_priorities\)\>/
+" Sendmail mode specific commands.
+syntax match msmtpOption /\<\(auto_from\|from\|maildomain\|dsn_notify\|dsn_return\|keepbcc\|logfile\|syslog\)\>/
+
+
+" Options which accept only an on/off value.
+syn match msmtpWrongOption /\<\(tls\|tls_certcheck\|tls_starttls\|tls_force_sslv3\|auto_from\|keepbcc\) \(on$\|off$\)\@!.*$/
+" Option port accepts numeric values.
+syn match msmtpWrongOption /\<port \(\d\+$\)\@!.*$/
+" Option timeout accepts off and numeric values.
+syn match msmtpWrongOption /\<timeout \(off$\|\d\+$\)\@!.*$/
+" Option protocol accepts smtp and lmtp.
+syn match msmtpWrongOption /\<protocol \(smtp$\|lmtp$\)\@!.*$/
+" Option auth accepts on, off and the method.
+syn match msmtpWrongOption /\<auth \(on$\|off$\|plain$\|cram-md5$\|digest-md5$\|scram-sha-1$\|gssapi$\|external$\|login$\|ntlm$\)\@!.*$/
+" Option auth accepts on, off and the facility.
+syn match msmtpWrongOption /\<syslog \(on$\|off$\|LOG_USER$\|LOG_MAIL$\|LOG_LOCAL\d$\)\@!.*$/
+
+" Marks all wrong option values as errors.
+syn match msmtpWrongOptionValue /\S* \zs.*$/ contained containedin=msmtpWrongOption
+
+" Mark the option part as a normal option.
+highlight default link msmtpWrongOption msmtpOption
+
+highlight default link msmtpComment Comment
+highlight default link msmtpOption Type
+highlight default link msmtpWrongOptionValue Error
+
+let b:current_syntax = "msmtp"
diff --git a/vim/vim/syntax/perl.vim b/vim/vim/syntax/perl.vim
new file mode 100644 (file)
index 0000000..9f653c2
--- /dev/null
@@ -0,0 +1,543 @@
+" Vim syntax file
+" Language:      Perl 5
+" Maintainer:    Andy Lester <andy@petdance.com>
+" Homepage:      http://github.com/petdance/vim-perl/tree/master
+" Bugs/requests: http://github.com/petdance/vim-perl/issues
+" Last Change:   2010-08-10
+" Contributors:  Andy Lester <andy@petdance.com>
+"                Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
+"                Lukas Mai <l.mai.web.de>
+"                Nick Hibma <nick@van-laarhoven.org>
+"                Sonia Heimann <niania@netsurf.org>
+"                and many others.
+"
+" Please download most recent version first before mailing
+" any comments.
+"
+" The following parameters are available for tuning the
+" perl syntax highlighting, with defaults given:
+"
+" unlet perl_include_pod
+" unlet perl_no_scope_in_variables
+" unlet perl_no_extended_vars
+" unlet perl_string_as_statement
+" unlet perl_no_sync_on_sub
+" unlet perl_no_sync_on_global_var
+" let perl_sync_dist = 100
+" unlet perl_fold
+" unlet perl_fold_blocks
+" let perl_nofold_packages = 1
+" let perl_nofold_subs = 1
+
+if exists("b:current_syntax")
+  finish
+endif
+
+
+" POD starts with ^=<word> and ends with ^=cut
+
+if exists("perl_include_pod")
+  " Include a while extra syntax file
+  syn include @Pod syntax/pod.vim
+  unlet b:current_syntax
+  if exists("perl_fold")
+    syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold
+    syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold
+  else
+    syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend
+    syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend
+  endif
+else
+  " Use only the bare minimum of rules
+  if exists("perl_fold")
+    syn region perlPOD start="^=[a-z]" end="^=cut" fold
+  else
+    syn region perlPOD start="^=[a-z]" end="^=cut"
+  endif
+endif
+
+
+syn cluster perlTop            contains=TOP
+syn region  perlGenericBlock   matchgroup=perlGenericBlock start="{" end="}" contained transparent
+
+
+" All keywords
+"
+syn match perlConditional              "\<\%(if\|elsif\|unless\|given\|when\|default\)\>"
+syn match perlConditional              "\<else\>" nextgroup=perlElseIfError skipwhite skipnl skipempty
+syn match perlRepeat                   "\<\%(while\|for\%(each\)\=\|do\|until\|continue\)\>"
+syn match perlOperator                 "\<\%(defined\|undef\|eq\|ne\|[gl][et]\|cmp\|not\|and\|or\|xor\|not\|bless\|ref\|do\)\>"
+syn match perlControl                  "\<\%(BEGIN\|CHECK\|INIT\|END\|UNITCHECK\)\>"
+
+syn match perlStatementStorage         "\<\%(my\|our\|local\|state\)\>"
+syn match perlStatementControl         "\<\%(return\|last\|next\|redo\|goto\|break\)\>"
+syn match perlStatementScalar          "\<\%(chom\=p\|chr\|crypt\|r\=index\|lc\%(first\)\=\|length\|ord\|pack\|sprintf\|substr\|uc\%(first\)\=\)\>"
+syn match perlStatementRegexp          "\<\%(pos\|quotemeta\|split\|study\)\>"
+syn match perlStatementNumeric         "\<\%(abs\|atan2\|cos\|exp\|hex\|int\|log\|oct\|rand\|sin\|sqrt\|srand\)\>"
+syn match perlStatementList            "\<\%(splice\|unshift\|shift\|push\|pop\|join\|reverse\|grep\|map\|sort\|unpack\)\>"
+syn match perlStatementHash            "\<\%(delete\|each\|exists\|keys\|values\)\>"
+syn match perlStatementIOfunc          "\<\%(syscall\|dbmopen\|dbmclose\)\>"
+syn match perlStatementFiledesc                "\<\%(binmode\|close\%(dir\)\=\|eof\|fileno\|getc\|lstat\|printf\=\|read\%(dir\|line\|pipe\)\|rewinddir\|say\|select\|stat\|tell\%(dir\)\=\|write\)\>" nextgroup=perlFiledescStatementNocomma skipwhite
+syn match perlStatementFiledesc                "\<\%(fcntl\|flock\|ioctl\|open\%(dir\)\=\|read\|seek\%(dir\)\=\|sys\%(open\|read\|seek\|write\)\|truncate\)\>" nextgroup=perlFiledescStatementComma skipwhite
+syn match perlStatementVector          "\<vec\>"
+syn match perlStatementFiles           "\<\%(ch\%(dir\|mod\|own\|root\)\|glob\|link\|mkdir\|readlink\|rename\|rmdir\|symlink\|umask\|unlink\|utime\)\>"
+syn match perlStatementFiles           "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>"
+syn match perlStatementFlow            "\<\%(caller\|die\|dump\|eval\|exit\|wantarray\)\>"
+syn match perlStatementInclude         "\<require\>"
+syn match perlStatementInclude         "\<\%(use\|no\)\s\+\%(\%(attributes\|attrs\|autouse\|parent\|base\|big\%(int\|num\|rat\)\|blib\|bytes\|charnames\|constant\|diagnostics\|encoding\%(::warnings\)\=\|feature\|fields\|filetest\|if\|integer\|less\|lib\|locale\|mro\|open\|ops\|overload\|re\|sigtrap\|sort\|strict\|subs\|threads\%(::shared\)\=\|utf8\|vars\|version\|vmsish\|warnings\%(::register\)\=\)\>\)\="
+syn match perlStatementProc            "\<\%(alarm\|exec\|fork\|get\%(pgrp\|ppid\|priority\)\|kill\|pipe\|set\%(pgrp\|priority\)\|sleep\|system\|times\|wait\%(pid\)\=\)\>"
+syn match perlStatementSocket          "\<\%(acept\|bind\|connect\|get\%(peername\|sock\%(name\|opt\)\)\|listen\|recv\|send\|setsockopt\|shutdown\|socket\%(pair\)\=\)\>"
+syn match perlStatementIPC             "\<\%(msg\%(ctl\|get\|rcv\|snd\)\|sem\%(ctl\|get\|op\)\|shm\%(ctl\|get\|read\|write\)\)\>"
+syn match perlStatementNetwork         "\<\%(\%(end\|[gs]et\)\%(host\|net\|proto\|serv\)ent\|get\%(\%(host\|net\)by\%(addr\|name\)\|protoby\%(name\|number\)\|servby\%(name\|port\)\)\)\>"
+syn match perlStatementPword           "\<\%(get\%(pw\%(uid\|nam\)\|gr\%(gid\|nam\)\|login\)\)\|\%(end\|[gs]et\)\%(pw\|gr\)ent\>"
+syn match perlStatementTime            "\<\%(gmtime\|localtime\|time\)\>"
+
+syn match perlStatementMisc            "\<\%(warn\|formline\|reset\|scalar\|prototype\|lock\|tied\=\|untie\)\>"
+
+syn keyword perlTodo                   TODO TBD FIXME XXX NOTE contained
+
+syn region perlStatementIndirObjWrap   matchgroup=perlStatementIndirObj start="\<\%(map\|grep\|sort\|print\|system\|exec\)\>\s*{" end="}" contains=@perlTop,perlGenericBlock
+
+syn match perlLabel      "^\s*\h\w*\s*::\@!\%(\<v\d\+\s*:\)\@<!"
+
+" Perl Identifiers.
+"
+" Should be cleaned up to better handle identifiers in particular situations
+" (in hash keys for example)
+"
+" Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
+" We do not process complex things such as @{${"foo"}}. Too complicated, and
+" too slow. And what is after the -> is *not* considered as part of the
+" variable - there again, too complicated and too slow.
+
+" Special variables first ($^A, ...) and ($|, $', ...)
+syn match  perlVarPlain                 "$^[ACDEFHILMNOPRSTVWX]\="
+syn match  perlVarPlain                 "$[\\\"\[\]'&`+*.,;=%~!?@#$<>(-]"
+syn match  perlVarPlain                 "%+"
+syn match  perlVarPlain                 "$\%(0\|[1-9]\d*\)"
+" Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
+syn match  perlVarPlain                 "$::\@!"
+" These variables are not recognized within matches.
+syn match  perlVarNotInMatches  "$[|)]"
+" This variable is not recognized within matches delimited by m//.
+syn match  perlVarSlash                 "$/"
+
+" And plain identifiers
+syn match  perlPackageRef       "[$@#%*&]\%(\%(::\|'\)\=\I\i*\%(\%(::\|'\)\I\i*\)*\)\=\%(::\|'\)\I"ms=s+1,me=e-1 contained
+
+" To not highlight packages in variables as a scope reference - i.e. in
+" $pack::var, pack:: is a scope, just set "perl_no_scope_in_variables"
+" If you don't want complex things like @{${"foo"}} to be processed,
+" just set the variable "perl_no_extended_vars"...
+
+if !exists("perl_no_scope_in_variables")
+  syn match  perlVarPlain       "\%([@$]\|\$#\)\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn match  perlVarPlain2                   "%\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef
+  syn match  perlFunctionName                "&\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+else
+  syn match  perlVarPlain       "\%([@$]\|\$#\)\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn match  perlVarPlain2                   "%\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)"
+  syn match  perlFunctionName                "&\$*\%(\I\i*\)\=\%(\%(::\|'\)\I\i*\)*\%(::\|\i\@<=\)" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+endif
+
+if !exists("perl_no_extended_vars")
+  syn cluster perlExpr         contains=perlStatementIndirObjWrap,perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarPlain2,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlVarBlock2,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ,perlArrow,perlGenericBlock
+  syn region perlArrow         matchgroup=perlArrow start="->\s*(" end=")" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+  syn region perlArrow         matchgroup=perlArrow start="->\s*\[" end="\]" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+  syn region perlArrow         matchgroup=perlArrow start="->\s*{" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+  syn match  perlArrow         "->\s*{\s*\I\i*\s*}" contains=perlVarSimpleMemberName nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+  syn region perlArrow         matchgroup=perlArrow start="->\s*\$*\I\i*\s*(" end=")" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contained
+  syn region perlVarBlock      matchgroup=perlVarPlain start="\%($#\|[$@]\)\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn region perlVarBlock2     matchgroup=perlVarPlain start="[%&*]\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn match  perlVarPlain2     "[%&*]\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn match  perlVarPlain      "\%(\$#\|[@$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn region perlVarMember     matchgroup=perlVarPlain start="\%(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn match  perlVarSimpleMember       "\%(->\)\={\s*\I\i*\s*}" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod contains=perlVarSimpleMemberName contained
+  syn match  perlVarSimpleMemberName   "\I\i*" contained
+  syn region perlVarMember     matchgroup=perlVarPlain start="\%(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
+  syn match perlPackageConst   "__PACKAGE__" nextgroup=perlMethod
+  syn match  perlMethod                "->\$*\I\i*" contained nextgroup=perlVarSimpleMember,perlVarMember,perlMethod
+endif
+
+" File Descriptors
+syn match  perlFiledescRead    "<\h\w*>"
+
+syn match  perlFiledescStatementComma  "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement
+syn match  perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^, \t]"me=e-1 transparent contained contains=perlFiledescStatement
+
+syn match  perlFiledescStatement       "\u\w*" contained
+
+" Special characters in strings and matches
+syn match  perlSpecialString   "\\\%(\o\{1,3}\|x\%({\x\+}\|\x\{1,2}\)\|c.\|[^cx]\)" contained extend
+syn match  perlSpecialStringU2 "\\." extend contained transparent contains=NONE
+syn match  perlSpecialStringU  "\\\\" contained
+syn match  perlSpecialMatch    "\\[1-9]" contained extend
+syn match  perlSpecialMatch    "\\g\%(\d\+\|{\%(-\=\d\+\|\h\w*\)}\)" contained
+syn match  perlSpecialMatch    "\\k\%(<\h\w*>\|'\h\w*'\)" contained
+syn match  perlSpecialMatch    "{\d\+\%(,\%(\d\+\)\=\)\=}" contained
+syn match  perlSpecialMatch    "\[[]-]\=[^\[\]]*[]-]\=\]" contained
+syn match  perlSpecialMatch    "[+*()?.]" contained
+syn match  perlSpecialMatch    "(?[#:=!]" contained
+syn match  perlSpecialMatch    "(?[impsx]*\%(-[imsx]\+\)\=)" contained
+syn match  perlSpecialMatch    "(?\%([-+]\=\d\+\|R\))" contained
+syn match  perlSpecialMatch    "(?\%(&\|P[>=]\)\h\w*)" contained
+syn match  perlSpecialMatch    "(\*\%(\%(PRUNE\|SKIP\|THEN\)\%(:[^)]*\)\=\|\%(MARK\|\):[^)]*\|COMMIT\|F\%(AIL\)\=\|ACCEPT\))" contained
+
+" Possible errors
+"
+" Highlight lines with only whitespace (only in blank delimited here documents) as errors
+syn match  perlNotEmptyLine    "^\s\+$" contained
+" Highlight "} else if (...) {", it should be "} else { if (...) { " or "} elsif (...) {"
+syn match perlElseIfError      "\s\+if" contained
+syn keyword perlElseIfError    elseif
+
+" Variable interpolation
+"
+" These items are interpolated inside "" strings and similar constructs.
+syn cluster perlInterpDQ       contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock
+" These items are interpolated inside '' strings and similar constructs.
+syn cluster perlInterpSQ       contains=perlSpecialStringU,perlSpecialStringU2
+" These items are interpolated inside m// matches and s/// substitutions.
+syn cluster perlInterpSlash    contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock
+" These items are interpolated inside m## matches and s### substitutions.
+syn cluster perlInterpMatch    contains=@perlInterpSlash,perlVarSlash
+
+" Shell commands
+syn region  perlShellCommand   matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ keepend
+
+" Constants
+"
+" Numbers
+syn match  perlNumber  "\<\%(0\%(x\x[[:xdigit:]_]*\|b[01][01_]*\|\o[0-7_]*\|\)\|[1-9][[:digit:]_]*\)\>"
+syn match  perlFloat   "\<\d[[:digit:]_]*[eE][\-+]\=\d\+"
+syn match  perlFloat   "\<\d[[:digit:]_]*\.[[:digit:]_]*\%([eE][\-+]\=\d\+\)\="
+syn match  perlFloat   "\.[[:digit:]_]\+\%([eE][\-+]\=\d\+\)\="
+
+syn match  perlString  "\<\%(v\d\+\%(\.\d\+\)*\|\d\+\%(\.\d\+\)\{2,}\)\>" contains=perlVStringV
+syn match  perlVStringV        "\<v" contained
+
+
+syn region perlParensSQ                start=+(+ end=+)+ extend contained transparent contains=perlParensSQ,@perlInterpSQ keepend
+syn region perlBracketsSQ      start=+\[+ end=+\]+ extend contained transparent contains=perlBracketsSQ,@perlInterpSQ keepend
+syn region perlBracesSQ                start=+{+ end=+}+ extend contained transparent contains=perlBracesSQ,@perlInterpSQ keepend
+syn region perlAnglesSQ                start=+<+ end=+>+ extend contained transparent contains=perlAnglesSQ,@perlInterpSQ keepend
+
+syn region perlParensDQ                start=+(+ end=+)+ extend contained transparent contains=perlParensDQ,@perlInterpDQ keepend
+syn region perlBracketsDQ      start=+\[+ end=+\]+ extend contained transparent contains=perlBracketsDQ,@perlInterpDQ keepend
+syn region perlBracesDQ                start=+{+ end=+}+ extend contained transparent contains=perlBracesDQ,@perlInterpDQ keepend
+syn region perlAnglesDQ                start=+<+ end=+>+ extend contained transparent contains=perlAnglesDQ,@perlInterpDQ keepend
+
+
+" Simple version of searches and matches
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\>\s*\z([^[:space:]'([{<#]\)+ end=+\z1[cgimopsx]*+ contains=@perlInterpMatch keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m#+ end=+#[cgimopsx]*+ contains=@perlInterpMatch keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*'+ end=+'[cgimopsx]*+ contains=@perlInterpSQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*/+ end=+/[cgimopsx]*+ contains=@perlInterpSlash keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*(+ end=+)[cgimopsx]*+ contains=@perlInterpMatch,perlParensDQ keepend
+
+" A special case for m{}, m<> and m[] which allows for comments and extra whitespace in the pattern
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*{+ end=+}[cgimopsx]*+ contains=@perlInterpMatch,perlComment,perlBracesDQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*<+ end=+>[cgimopsx]*+ contains=@perlInterpMatch,perlAnglesDQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!m\s*\[+ end=+\][cgimopsx]*+ contains=@perlInterpMatch,perlComment,perlBracketsDQ keepend
+
+" Below some hacks to recognise the // variant. This is virtually impossible to catch in all
+" cases as the / is used in so many other ways, but these should be the most obvious ones.
+syn region perlMatch   matchgroup=perlMatchStartEnd start="\%([$@%&*]\@<!\%(\<split\|\<while\|\<if\|\<unless\|\.\.\|[-+*!~(\[{=]\)\s*\)\@<=/\%(/=\)\@!" start=+^/\%(/=\)\@!+ start=+\s\@<=/\%(/=\)\@![^[:space:][:digit:]$@%=]\@=\%(/\_s*\%([([{$@%&*[:digit:]"'`]\|\_s\w\|[[:upper:]_abd-fhjklnqrt-wyz]\)\)\@!+ skip=+\\/+ end=+/[cgimopsx]*+ contains=@perlInterpSlash
+
+
+" Substitutions
+" perlMatch is the first part, perlSubstitution* is the substitution part
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\>\s*\z([^[:space:]'([{<#]\)+ end=+\z1+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionGQQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*'+  end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*/+  end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionGQQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s#+  end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionGQQ keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*(+ end=+)+ contains=@perlInterpMatch,perlParensDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*<+ end=+>+ contains=@perlInterpMatch,perlAnglesDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*\[+ end=+\]+ contains=@perlInterpMatch,perlBracketsDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!s\s*{+ end=+}+ contains=@perlInterpMatch,perlBracesDQ nextgroup=perlSubstitutionGQQ skipwhite skipempty skipnl keepend
+syn region perlSubstitutionGQQ         matchgroup=perlMatchStartEnd start=+\z([^[:space:]'([{<]\)+ end=+\z1[ecgimopsx]*+ keepend contained contains=@perlInterpDQ
+syn region perlSubstitutionGQQ         matchgroup=perlMatchStartEnd start=+(+ end=+)[ecgimopsx]*+ contained contains=@perlInterpDQ,perlParensDQ keepend
+syn region perlSubstitutionGQQ         matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimopsx]*+ contained contains=@perlInterpDQ,perlBracketsDQ keepend
+syn region perlSubstitutionGQQ         matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimopsx]*+ contained contains=@perlInterpDQ,perlBracesDQ keepend
+syn region perlSubstitutionGQQ         matchgroup=perlMatchStartEnd start=+<+ end=+>[ecgimopsx]*+ contained contains=@perlInterpDQ,perlAnglesDQ keepend
+syn region perlSubstitutionSQ          matchgroup=perlMatchStartEnd start=+'+  end=+'[ecgimopsx]*+ contained contains=@perlInterpSQ keepend 
+
+" Translations
+" perlMatch is the first part, perlTranslation* is the second, translator part.
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\>\s*\z([^[:space:]([{<#]\)+ end=+\z1+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationGQ
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationGQ
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlMatch   matchgroup=perlMatchStartEnd start=+\<\%(::\|'\|->\)\@<!\%(tr\|y\)\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ nextgroup=perlTranslationGQ skipwhite skipempty skipnl
+syn region perlTranslationGQ           matchgroup=perlMatchStartEnd start=+\z([^[:space:]([{<]\)+ end=+\z1[cds]*+ contained
+syn region perlTranslationGQ           matchgroup=perlMatchStartEnd start=+(+ end=+)[cds]*+ contains=perlParensSQ contained
+syn region perlTranslationGQ           matchgroup=perlMatchStartEnd start=+\[+ end=+\][cds]*+ contains=perlBracketsSQ contained
+syn region perlTranslationGQ           matchgroup=perlMatchStartEnd start=+{+ end=+}[cds]*+ contains=perlBracesSQ contained
+syn region perlTranslationGQ           matchgroup=perlMatchStartEnd start=+<+ end=+>[cds]*+ contains=perlAnglesSQ contained
+
+
+" Strings and q, qq, qw and qr expressions
+
+syn region perlStringUnexpanded        matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ keepend
+syn region perlString          matchgroup=perlStringStartEnd start=+"+  end=+"+ contains=@perlInterpDQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\>\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q#+ end=+#+ contains=@perlInterpSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*(+ end=+)+ contains=@perlInterpSQ,perlParensSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*\[+ end=+\]+ contains=@perlInterpSQ,perlBracketsSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend
+
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\>\s*\z([^[:space:]#([{<]\)+ end=+\z1+ contains=@perlInterpDQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]#+ end=+#+ contains=@perlInterpDQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*(+ end=+)+ contains=@perlInterpDQ,perlParensDQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*\[+ end=+\]+ contains=@perlInterpDQ,perlBracketsDQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*{+ end=+}+ contains=@perlInterpDQ,perlBracesDQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!q[qx]\s*<+ end=+>+ contains=@perlInterpDQ,perlAnglesDQ keepend
+
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*\z([^[:space:]#([{<]\)+  end=+\z1+ contains=@perlInterpSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw#+  end=+#+ contains=@perlInterpSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*(+  end=+)+ contains=@perlInterpSQ,perlParensSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*\[+  end=+\]+ contains=@perlInterpSQ,perlBracketsSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*{+  end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*<+  end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend
+
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\>\s*\z([^[:space:]#([{<'/]\)+  end=+\z1[imosx]*+ contains=@perlInterpMatch keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*/+  end=+/[imosx]*+ contains=@perlInterpSlash keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr#+  end=+#[imosx]*+ contains=@perlInterpMatch keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*'+  end=+'[imosx]*+ contains=@perlInterpSQ keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*(+  end=+)[imosx]*+ contains=@perlInterpMatch,perlParensDQ keepend
+
+" A special case for qr{}, qr<> and qr[] which allows for comments and extra whitespace in the pattern
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*{+  end=+}[imosx]*+ contains=@perlInterpMatch,perlBracesDQ,perlComment keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*<+  end=+>[imosx]*+ contains=@perlInterpMatch,perlAnglesDQ,perlComment keepend
+syn region perlQQ              matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*\[+  end=+\][imosx]*+ contains=@perlInterpMatch,perlBracketsDQ,perlComment keepend
+
+" Constructs such as print <<EOF [...] EOF, 'here' documents
+"
+" XXX Any statements after the identifier are in perlString colour (i.e.
+" 'if $a' in 'print <<EOF if $a'). This is almost impossible to get right it
+" seems due to the 'auto-extending nature' of regions.
+if exists("perl_fold")
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\z(\I\i*\).*+    end=+^\z1$+ contains=@perlInterpDQ fold
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*"\z([^\\"]*\%(\\.[^\\"]*\)*\)"+ end=+^\z1$+ contains=@perlInterpDQ fold
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ end=+^\z1$+ contains=@perlInterpSQ fold
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*""+           end=+^$+    contains=@perlInterpDQ,perlNotEmptyLine fold
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*''+           end=+^$+    contains=@perlInterpSQ,perlNotEmptyLine fold
+  syn region perlAutoload      matchgroup=perlStringStartEnd start=+<<\s*\(['"]\=\)\z(END_\%(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL fold
+else
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+    end=+^\z1$+ contains=@perlInterpDQ
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*"\z([^\\"]*\%(\\.[^\\"]*\)*\)"+ end=+^\z1$+ contains=@perlInterpDQ
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ end=+^\z1$+ contains=@perlInterpSQ
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*""+           end=+^$+    contains=@perlInterpDQ,perlNotEmptyLine
+  syn region perlHereDoc       matchgroup=perlStringStartEnd start=+<<\s*''+           end=+^$+    contains=@perlInterpSQ,perlNotEmptyLine
+  syn region perlAutoload      matchgroup=perlStringStartEnd start=+<<\s*\(['"]\=\)\z(END_\%(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL
+endif
+
+
+" Class declarations
+"
+syn match   perlPackageDecl            "\<package\s\+\%(\h\|::\)\%(\w\|::\)*" contains=perlStatementPackage
+syn keyword perlStatementPackage       package contained
+
+" Functions
+"       sub [name] [(prototype)] {
+"
+syn match perlSubError "[^[:space:];{#]" contained
+if v:version == 701 && !has('patch221')  " XXX I hope that's the right one
+    syn match perlSubAttributes ":" contained
+else
+    syn match perlSubAttributesCont "\h\w*\_s*\%(:\_s*\)\=" nextgroup=@perlSubAttrMaybe contained
+    syn region perlSubAttributesCont matchgroup=perlSubAttributesCont start="\h\w*(" end=")\_s*\%(:\_s*\)\=" nextgroup=@perlSubAttrMaybe contained contains=@perlInterpSQ,perlParensSQ
+    syn cluster perlSubAttrMaybe contains=perlSubAttributesCont,perlSubError
+    syn match perlSubAttributes "" contained nextgroup=perlSubError
+    syn match perlSubAttributes ":\_s*" contained nextgroup=@perlSubAttrMaybe
+endif
+syn match perlSubPrototypeError "(\%(\_s*\%(\%(\\\%([$@%&*]\|\[[$@%&*]\+\]\)\|[$&*]\|[@%]\%(\_s*)\)\@=\|;\%(\_s*[)$@%&*\\]\)\@=\|_\%(\_s*[);]\)\@=\)\_s*\)*\)\@>\zs\_[^)]\+" contained
+syn match perlSubPrototype +(\_[^)]*)\_s*\|+ nextgroup=perlSubAttributes contained contains=perlSubPrototypeError
+syn match perlSubName +\%(\h\|::\|'\w\)\%(\w\|::\|'\w\)*\_s*\|+ contained nextgroup=perlSubPrototype
+
+syn match perlFunction +\<sub\>\_s*+ nextgroup=perlSubName
+
+if !exists("perl_no_scope_in_variables")
+   syn match  perlFunctionPRef "\h\w*::" contained
+   syn match  perlFunctionName "\h\w*[^:]" contained
+else
+   syn match  perlFunctionName "\h[[:alnum:]_:]*" contained
+endif
+
+" The => operator forces a bareword to the left of it to be interpreted as
+" a string
+syn match  perlString "\I\@<!-\?\I\i*\%(\s*=>\)\@="
+
+" All other # are comments, except ^#!
+syn match  perlComment         "#.*" contains=perlTodo,@Spell
+syn match  perlSharpBang       "^#!.*"
+
+" Formats
+syn region perlFormat          matchgroup=perlStatementIOFunc start="^\s*\<format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain,perlVarPlain2
+syn match  perlFormatName      "format\s\+\k\+\s*="lc=7,me=e-1 contained
+syn match  perlFormatField     "[@^][|<>~]\+\%(\.\.\.\)\=" contained
+syn match  perlFormatField     "[@^]#[#.]*" contained
+syn match  perlFormatField     "@\*" contained
+syn match  perlFormatField     "@[^A-Za-z_|<>~#*]"me=e-1 contained
+syn match  perlFormatField     "@$" contained
+
+" __END__ and __DATA__ clauses
+if exists("perl_fold")
+  syntax region perlDATA               start="^__\%(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA fold
+else
+  syntax region perlDATA               start="^__\%(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA
+endif
+
+"
+" Folding
+
+if exists("perl_fold")
+  " Note: this bit must come before the actual highlighting of the "package"
+  " keyword, otherwise this will screw up Pod lines that match /^package/
+  if !exists("perl_nofold_packages")
+    syn region perlPackageFold start="^package \S\+;\s*\%(#.*\)\=$" end="^1;\=\s*\%(#.*\)\=$" end="\n\+package"me=s-1 transparent fold keepend
+  endif
+  if !exists("perl_nofold_subs")
+    syn region perlSubFold     start="^\z(\s*\)\<sub\>.*[^};]$" end="^\z1}\s*\%(#.*\)\=$" transparent fold keepend
+    syn region perlSubFold start="^\z(\s*\)\<\%(BEGIN\|END\|CHECK\|INIT\|UNITCHECK\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
+  endif
+
+  if exists("perl_fold_blocks")
+    syn region perlBlockFold start="^\z(\s*\)\%(if\|elsif\|unless\|for\|while\|until\|given\)\s*(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" start="^\z(\s*\)foreach\s*\%(\%(my\|our\)\=\s*\S\+\s*\)\=(.*)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend
+    syn region perlBlockFold start="^\z(\s*\)\%(do\|else\)\%(\s*{\)\=\s*\%(#.*\)\=$" end="^\z1}\s*while" end="^\z1}\s*;\=\%(#.*\)\=$" transparent fold keepend
+  endif
+
+  setlocal foldmethod=syntax
+  syn sync fromstart
+else
+  " fromstart above seems to set minlines even if perl_fold is not set.
+  syn sync minlines=0
+endif
+
+command -nargs=+ HiLink hi def link <args>
+
+" The default highlighting.
+HiLink perlSharpBang           PreProc
+HiLink perlControl             PreProc
+HiLink perlInclude             Include
+HiLink perlSpecial             Special
+HiLink perlString              String
+HiLink perlCharacter           Character
+HiLink perlNumber              Number
+HiLink perlFloat               Float
+HiLink perlType                        Type
+HiLink perlIdentifier          Identifier
+HiLink perlLabel               Label
+HiLink perlStatement           Statement
+HiLink perlConditional         Conditional
+HiLink perlRepeat              Repeat
+HiLink perlOperator            Operator
+HiLink perlFunction            Keyword
+HiLink perlSubName             Function
+HiLink perlSubPrototype                Type
+HiLink perlSubAttributes       PreProc
+HiLink perlSubAttributesCont   perlSubAttributes
+HiLink perlComment             Comment
+HiLink perlTodo                        Todo
+if exists("perl_string_as_statement")
+  HiLink perlStringStartEnd    perlStatement
+else
+  HiLink perlStringStartEnd    perlString
+endif
+HiLink perlVStringV            perlStringStartEnd
+HiLink perlList                        perlStatement
+HiLink perlMisc                        perlStatement
+HiLink perlVarPlain            perlIdentifier
+HiLink perlVarPlain2           perlIdentifier
+HiLink perlArrow               perlIdentifier
+HiLink perlFiledescRead                perlIdentifier
+HiLink perlFiledescStatement   perlIdentifier
+HiLink perlVarSimpleMember     perlIdentifier
+HiLink perlVarSimpleMemberName         perlString
+HiLink perlVarNotInMatches     perlIdentifier
+HiLink perlVarSlash            perlIdentifier
+HiLink perlQQ                  perlString
+HiLink perlHereDoc             perlString
+HiLink perlStringUnexpanded    perlString
+HiLink perlSubstitutionSQ      perlString
+HiLink perlSubstitutionGQQ     perlString
+HiLink perlTranslationGQ       perlString
+HiLink perlMatch               perlString
+HiLink perlMatchStartEnd       perlStatement
+HiLink perlFormatName          perlIdentifier
+HiLink perlFormatField         perlString
+HiLink perlPackageDecl         perlType
+HiLink perlStorageClass                perlType
+HiLink perlPackageRef          perlType
+HiLink perlStatementPackage    perlStatement
+HiLink perlStatementStorage    perlStatement
+HiLink perlStatementControl    perlStatement
+HiLink perlStatementScalar     perlStatement
+HiLink perlStatementRegexp     perlStatement
+HiLink perlStatementNumeric    perlStatement
+HiLink perlStatementList       perlStatement
+HiLink perlStatementHash       perlStatement
+HiLink perlStatementIOfunc     perlStatement
+HiLink perlStatementFiledesc   perlStatement
+HiLink perlStatementVector     perlStatement
+HiLink perlStatementFiles      perlStatement
+HiLink perlStatementFlow       perlStatement
+HiLink perlStatementInclude    perlStatement
+HiLink perlStatementProc       perlStatement
+HiLink perlStatementSocket     perlStatement
+HiLink perlStatementIPC                perlStatement
+HiLink perlStatementNetwork    perlStatement
+HiLink perlStatementPword      perlStatement
+HiLink perlStatementTime       perlStatement
+HiLink perlStatementMisc       perlStatement
+HiLink perlStatementIndirObj   perlStatement
+HiLink perlFunctionName                perlIdentifier
+HiLink perlMethod              perlIdentifier
+HiLink perlFunctionPRef                perlType
+HiLink perlPOD                 perlComment
+HiLink perlShellCommand                perlString
+HiLink perlSpecialAscii                perlSpecial
+HiLink perlSpecialDollar       perlSpecial
+HiLink perlSpecialString       perlSpecial
+HiLink perlSpecialStringU      perlSpecial
+HiLink perlSpecialMatch                perlSpecial
+HiLink perlDATA                        perlComment
+
+" Possible errors
+HiLink perlNotEmptyLine                Error
+HiLink perlElseIfError         Error
+HiLink perlSubPrototypeError   Error
+HiLink perlSubError            Error
+
+delcommand HiLink
+
+" Syncing to speed up processing
+"
+if !exists("perl_no_sync_on_sub")
+  syn sync match perlSync      grouphere NONE "^\s*\<package\s"
+  syn sync match perlSync      grouphere NONE "^\s*\<sub\>"
+  syn sync match perlSync      grouphere NONE "^}"
+endif
+
+if !exists("perl_no_sync_on_global_var")
+  syn sync match perlSync      grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
+  syn sync match perlSync      grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
+endif
+
+if exists("perl_sync_dist")
+  execute "syn sync maxlines=" . perl_sync_dist
+else
+  syn sync maxlines=100
+endif
+
+syn sync match perlSyncPOD     grouphere perlPOD "^=pod"
+syn sync match perlSyncPOD     grouphere perlPOD "^=head"
+syn sync match perlSyncPOD     grouphere perlPOD "^=item"
+syn sync match perlSyncPOD     grouphere NONE "^=cut"
+
+let b:current_syntax = "perl"
+
+" XXX Change to sts=4:sw=4
+" vim:ts=8:sts=2:sw=2:expandtab:ft=vim
diff --git a/vim/vim/syntax/python.vim b/vim/vim/syntax/python.vim
new file mode 100644 (file)
index 0000000..0e0bb12
--- /dev/null
@@ -0,0 +1,374 @@
+" Vim syntax file
+" Language:    Python
+" Maintainer:  Dmitry Vasiliev <dima@hlabs.spb.ru>
+" URL:         http://www.hlabs.spb.ru/vim/python.vim
+" Last Change: 2010-04-09
+" Filenames:   *.py
+" Version:     2.6.6
+"
+" Based on python.vim (from Vim 6.1 distribution)
+" by Neil Schemenauer <nas@python.ca>
+"
+" Thanks:
+"
+"    Jeroen Ruigrok van der Werven
+"        for the idea to highlight erroneous operators
+"    Pedro Algarvio
+"        for the patch to enable spell checking only for the right spots
+"        (strings and comments)
+"    John Eikenberry
+"        for the patch fixing small typo
+"    Caleb Adamantine
+"        for the patch fixing highlighting for decorators
+"    Andrea Riciputi
+"        for the patch with new configuration options
+
+"
+" Options:
+"
+"    For set option do: let OPTION_NAME = 1
+"    For clear option do: let OPTION_NAME = 0
+"
+" Option names:
+"
+"    For highlight builtin functions and objects:
+"       python_highlight_builtins
+"
+"    For highlight builtin objects:
+"       python_highlight_builtin_objs
+"
+"    For highlight builtin funtions:
+"       python_highlight_builtin_funcs
+"
+"    For highlight standard exceptions:
+"       python_highlight_exceptions
+"
+"    For highlight string formatting:
+"       python_highlight_string_formatting
+"
+"    For highlight str.format syntax:
+"       python_highlight_string_format
+"
+"    For highlight string.Template syntax:
+"       python_highlight_string_templates
+"
+"    For highlight indentation errors:
+"       python_highlight_indent_errors
+"
+"    For highlight trailing spaces:
+"       python_highlight_space_errors
+"
+"    For highlight doc-tests:
+"       python_highlight_doctests
+"
+"    If you want all Python highlightings above:
+"       python_highlight_all
+"    (This option not override previously set options)
+"
+"    For fast machines:
+"       python_slow_sync
+"
+"    For "print" builtin as function:
+"       python_print_as_function
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+if exists("python_highlight_all") && python_highlight_all != 0
+  " Not override previously set options
+  if !exists("python_highlight_builtins")
+    if !exists("python_highlight_builtin_objs")
+      let python_highlight_builtin_objs = 1
+    endif
+    if !exists("python_highlight_builtin_funcs")
+      let python_highlight_builtin_funcs = 1
+    endif
+  endif
+  if !exists("python_highlight_exceptions")
+    let python_highlight_exceptions = 1
+  endif
+  if !exists("python_highlight_string_formatting")
+    let python_highlight_string_formatting = 1
+  endif
+  if !exists("python_highlight_string_format")
+    let python_highlight_string_format = 1
+  endif
+  if !exists("python_highlight_string_templates")
+    let python_highlight_string_templates = 1
+  endif
+  if !exists("python_highlight_indent_errors")
+    let python_highlight_indent_errors = 1
+  endif
+  if !exists("python_highlight_space_errors")
+    let python_highlight_space_errors = 1
+  endif
+  if !exists("python_highlight_doctests")
+    let python_highlight_doctests = 1
+  endif
+endif
+
+" Keywords
+syn keyword pythonStatement    break continue del
+syn keyword pythonStatement    exec return
+syn keyword pythonStatement    pass raise
+syn keyword pythonStatement    global assert
+syn keyword pythonStatement    lambda yield
+syn keyword pythonStatement    with
+syn keyword pythonStatement    def class nextgroup=pythonFunction skipwhite
+syn match   pythonFunction     "[a-zA-Z_][a-zA-Z0-9_]*" display contained
+syn keyword pythonRepeat       for while
+syn keyword pythonConditional  if elif else
+syn keyword pythonPreCondit    import from as
+syn keyword pythonException    try except finally
+syn keyword pythonOperator     and in is not or
+
+if !exists("python_print_as_function") || python_print_as_function == 0
+  syn keyword pythonStatement print
+endif
+
+" Decorators (new in Python 2.4)
+syn match   pythonDecorator    "@" display nextgroup=pythonDottedName skipwhite
+syn match   pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
+syn match   pythonDot        "\." display containedin=pythonDottedName
+
+" Comments
+syn match   pythonComment      "#.*$" display contains=pythonTodo,@Spell
+syn match   pythonRun          "\%^#!.*$"
+syn match   pythonCoding       "\%^.*\(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
+syn keyword pythonTodo         TODO FIXME XXX contained
+
+" Errors
+syn match pythonError          "\<\d\+\D\+\>" display
+syn match pythonError          "[$?]" display
+syn match pythonError          "[&|]\{2,}" display
+syn match pythonError          "[=]\{3,}" display
+
+" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline
+" statements. For now I don't know how to work around this.
+if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0
+  syn match pythonIndentError  "^\s*\( \t\|\t \)\s*\S"me=e-1 display
+endif
+
+" Trailing space errors
+if exists("python_highlight_space_errors") && python_highlight_space_errors != 0
+  syn match pythonSpaceError   "\s\+$" display
+endif
+
+" Strings
+syn region pythonString                start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
+syn region pythonString                start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
+syn region pythonString                start=+[bB]\="""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonString                start=+[bB]\='''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell
+
+syn match  pythonEscape                +\\[abfnrtv'"\\]+ display contained
+syn match  pythonEscape                "\\\o\o\=\o\=" display contained
+syn match  pythonEscapeError   "\\\o\{,2}[89]" display contained
+syn match  pythonEscape                "\\x\x\{2}" display contained
+syn match  pythonEscapeError   "\\x\x\=\X" display contained
+syn match  pythonEscape                "\\$"
+
+" Unicode strings
+syn region pythonUniString     start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
+syn region pythonUniString     start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
+syn region pythonUniString     start=+[uU]"""+ end=+"""+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonUniString     start=+[uU]'''+ end=+'''+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
+
+syn match  pythonUniEscape     "\\u\x\{4}" display contained
+syn match  pythonUniEscapeError        "\\u\x\{,3}\X" display contained
+syn match  pythonUniEscape     "\\U\x\{8}" display contained
+syn match  pythonUniEscapeError        "\\U\x\{,7}\X" display contained
+syn match  pythonUniEscape     "\\N{[A-Z ]\+}" display contained
+syn match  pythonUniEscapeError        "\\N{[^A-Z ]\+}" display contained
+
+" Raw strings
+syn region pythonRawString     start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
+syn region pythonRawString     start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
+syn region pythonRawString     start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonRawString     start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
+
+syn match pythonRawEscape      +\\['"]+ display transparent contained
+
+" Unicode raw strings
+syn region pythonUniRawString  start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
+syn region pythonUniRawString  start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
+syn region pythonUniRawString  start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
+syn region pythonUniRawString  start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
+
+syn match  pythonUniRawEscape          "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
+syn match  pythonUniRawEscapeError     "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
+
+if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
+  " String formatting
+  syn match pythonStrFormatting        "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+  syn match pythonStrFormatting        "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+endif
+
+if exists("python_highlight_string_format") && python_highlight_string_format != 0
+  " str.format syntax
+  syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+  syn match pythonStrFormat    "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+endif
+
+if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
+  " String templates
+  syn match pythonStrTemplate  "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+  syn match pythonStrTemplate  "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+  syn match pythonStrTemplate  "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
+endif
+
+if exists("python_highlight_doctests") && python_highlight_doctests != 0
+  " DocTests
+  syn region pythonDocTest     start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
+  syn region pythonDocTest2    start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
+endif
+
+" Numbers (ints, longs, floats, complex)
+syn match   pythonHexError     "\<0[xX]\x*[g-zG-Z]\x*[lL]\=\>" display
+
+syn match   pythonHexNumber    "\<0[xX]\x\+[lL]\=\>" display
+syn match   pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
+syn match   pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
+
+syn match   pythonNumber       "\<\d\+[lLjJ]\=\>" display
+
+syn match   pythonFloat                "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
+syn match   pythonFloat                "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
+syn match   pythonFloat                "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
+
+syn match   pythonOctError     "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
+syn match   pythonBinError     "\<0[bB][01]*[2-9]\d*[lL]\=\>" display
+
+if exists("python_highlight_builtin_objs") && python_highlight_builtin_objs != 0
+  " Builtin objects and types
+  syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented
+  syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
+endif
+
+if exists("python_highlight_builtin_funcs") && python_highlight_builtin_funcs != 0
+  " Builtin functions
+  syn keyword pythonBuiltinFunc        __import__ abs all any apply
+  syn keyword pythonBuiltinFunc        basestring bin bool buffer bytearray bytes callable
+  syn keyword pythonBuiltinFunc        chr classmethod cmp coerce compile complex
+  syn keyword pythonBuiltinFunc        delattr dict dir divmod enumerate eval
+  syn keyword pythonBuiltinFunc        execfile file filter float format frozenset getattr
+  syn keyword pythonBuiltinFunc        globals hasattr hash help hex id
+  syn keyword pythonBuiltinFunc        input int intern isinstance
+  syn keyword pythonBuiltinFunc        issubclass iter len list locals long map max
+  syn keyword pythonBuiltinFunc        min next object oct open ord
+  syn keyword pythonBuiltinFunc        pow property range
+  syn keyword pythonBuiltinFunc        raw_input reduce reload repr
+  syn keyword pythonBuiltinFunc        reversed round set setattr
+  syn keyword pythonBuiltinFunc        slice sorted staticmethod str sum super tuple
+  syn keyword pythonBuiltinFunc        type unichr unicode vars xrange zip
+
+  if exists("python_print_as_function") && python_print_as_function != 0
+      syn keyword pythonBuiltinFunc    print
+  endif
+endif
+
+if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
+  " Builtin exceptions and warnings
+  syn keyword pythonExClass    BaseException
+  syn keyword pythonExClass    Exception StandardError ArithmeticError
+  syn keyword pythonExClass    LookupError EnvironmentError
+
+  syn keyword pythonExClass    AssertionError AttributeError BufferError EOFError
+  syn keyword pythonExClass    FloatingPointError GeneratorExit IOError
+  syn keyword pythonExClass    ImportError IndexError KeyError
+  syn keyword pythonExClass    KeyboardInterrupt MemoryError NameError
+  syn keyword pythonExClass    NotImplementedError OSError OverflowError
+  syn keyword pythonExClass    ReferenceError RuntimeError StopIteration
+  syn keyword pythonExClass    SyntaxError IndentationError TabError
+  syn keyword pythonExClass    SystemError SystemExit TypeError
+  syn keyword pythonExClass    UnboundLocalError UnicodeError
+  syn keyword pythonExClass    UnicodeEncodeError UnicodeDecodeError
+  syn keyword pythonExClass    UnicodeTranslateError ValueError VMSError
+  syn keyword pythonExClass    WindowsError ZeroDivisionError
+
+  syn keyword pythonExClass    Warning UserWarning BytesWarning DeprecationWarning
+  syn keyword pythonExClass    PendingDepricationWarning SyntaxWarning
+  syn keyword pythonExClass    RuntimeWarning FutureWarning
+  syn keyword pythonExClass    ImportWarning UnicodeWarning
+endif
+
+if exists("python_slow_sync") && python_slow_sync != 0
+  syn sync minlines=2000
+else
+  " This is fast but code inside triple quoted strings screws it up. It
+  " is impossible to fix because the only way to know if you are inside a
+  " triple quoted string is to start from the beginning of the file.
+  syn sync match pythonSync grouphere NONE "):$"
+  syn sync maxlines=200
+endif
+
+if version >= 508 || !exists("did_python_syn_inits")
+  if version <= 508
+    let did_python_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+
+  HiLink pythonStatement       Statement
+  HiLink pythonPreCondit       Statement
+  HiLink pythonFunction                Function
+  HiLink pythonConditional     Conditional
+  HiLink pythonRepeat          Repeat
+  HiLink pythonException       Exception
+  HiLink pythonOperator                Operator
+
+  HiLink pythonDecorator       Define
+  HiLink pythonDottedName      Function
+  HiLink pythonDot          Normal
+
+  HiLink pythonComment         Comment
+  HiLink pythonCoding          Special
+  HiLink pythonRun             Special
+  HiLink pythonTodo            Todo
+
+  HiLink pythonError           Error
+  HiLink pythonIndentError     Error
+  HiLink pythonSpaceError      Error
+
+  HiLink pythonString          String
+  HiLink pythonUniString       String
+  HiLink pythonRawString       String
+  HiLink pythonUniRawString    String
+
+  HiLink pythonEscape                  Special
+  HiLink pythonEscapeError             Error
+  HiLink pythonUniEscape               Special
+  HiLink pythonUniEscapeError          Error
+  HiLink pythonUniRawEscape            Special
+  HiLink pythonUniRawEscapeError       Error
+
+  HiLink pythonStrFormatting   Special
+  HiLink pythonStrFormat       Special
+  HiLink pythonStrTemplate         Special
+
+  HiLink pythonDocTest         Special
+  HiLink pythonDocTest2                Special
+
+  HiLink pythonNumber          Number
+  HiLink pythonHexNumber       Number
+  HiLink pythonOctNumber       Number
+  HiLink pythonBinNumber       Number
+  HiLink pythonFloat           Float
+  HiLink pythonOctError            Error
+  HiLink pythonHexError                Error
+  HiLink pythonBinError                Error
+
+  HiLink pythonBuiltinObj      Structure
+  HiLink pythonBuiltinFunc     Function
+
+  HiLink pythonExClass Structure
+
+  delcommand HiLink
+endif
+
+let b:current_syntax = "python"
diff --git a/vim/vim/syntax/tmux.vim b/vim/vim/syntax/tmux.vim
new file mode 100644 (file)
index 0000000..58bceca
--- /dev/null
@@ -0,0 +1,103 @@
+" Vim syntax file
+" Language: tmux(1) configuration file
+" Maintainer: Tiago Cunha <me@tiagocunha.org>
+" Last Change: $Date: 2010/07/02 02:46:39 $
+" License: This file is placed in the public domain.
+
+if version < 600
+       syntax clear
+elseif exists("b:current_syntax")
+       finish
+endif
+
+setlocal iskeyword+=-
+syntax case match
+
+syn keyword tmuxAction any current none
+syn keyword tmuxBoolean        off on
+
+syn keyword tmuxCmds detach[-client] ls list-sessions neww new-window
+syn keyword tmuxCmds bind[-key] unbind[-key] prev[ious-window] last[-window]
+syn keyword tmuxCmds lsk list-keys set[-option] renamew rename-window selectw
+syn keyword tmuxCmds select-window lsw list-windows attach[-session]
+syn keyword tmuxCmds send-prefix refresh[-client] killw kill-window lsc
+syn keyword tmuxCmds list-clients linkw link-window unlinkw unlink-window
+syn keyword tmuxCmds next[-window] send[-keys] swapw swap-window
+syn keyword tmuxCmds rename[-session] kill-session switchc switch-client
+syn keyword tmuxCmds has[-session] copy-mode pasteb paste-buffer
+syn keyword tmuxCmds new[-session] start[-server] kill-server setw
+syn keyword tmuxCmds set-window-option show[-options] showw show-window-options
+syn keyword tmuxCmds command-prompt setb set-buffer showb show-buffer lsb
+syn keyword tmuxCmds list-buffers deleteb delete-buffer lscm list-commands
+syn keyword tmuxCmds movew move-window respawnw respawn-window
+syn keyword tmuxCmds source[-file] info server-info clock-mode lock[-server]
+syn keyword tmuxCmds saveb save-buffer downp down-pane killp
+syn keyword tmuxCmds kill-pane resizep resize-pane selectp select-pane swapp
+syn keyword tmuxCmds swap-pane splitw split-window upp up-pane choose-session
+syn keyword tmuxCmds choose-window loadb load-buffer copyb copy-buffer suspendc
+syn keyword tmuxCmds suspend-client findw find-window breakp break-pane nextl
+syn keyword tmuxCmds next-layout rotatew rotate-window confirm[-before]
+syn keyword tmuxCmds clearhist clear-history selectl select-layout if[-shell]
+syn keyword tmuxCmds display[-message] setenv set-environment showenv
+syn keyword tmuxCmds show-environment choose-client displayp display-panes
+syn keyword tmuxCmds run[-shell] lockc lock-client locks lock-session lsp
+syn keyword tmuxCmds list-panes pipep pipe-pane showmsgs show-messages capturep
+syn keyword tmuxCmds capture-pane joinp join-pane choose-buffer
+
+syn keyword tmuxOptsSet prefix status status-fg status-bg bell-action
+syn keyword tmuxOptsSet default-command history-limit status-left status-right
+syn keyword tmuxOptsSet status-interval set-titles display-time buffer-limit
+syn keyword tmuxOptsSet status-left-length status-right-length message-fg
+syn keyword tmuxOptsSet message-bg lock-after-time default-path repeat-time
+syn keyword tmuxOptsSet message-attr status-attr status-keys set-remain-on-exit
+syn keyword tmuxOptsSet status-utf8 default-terminal visual-activity
+syn keyword tmuxOptsSet visual-bell visual-content status-justify
+syn keyword tmuxOptsSet terminal-overrides status-left-attr status-left-bg
+syn keyword tmuxOptsSet status-left-fg status-right-attr status-right-bg
+syn keyword tmuxOptsSet status-right-fg update-environment base-index
+syn keyword tmuxOptsSet display-panes-colour display-panes-time default-shell
+syn keyword tmuxOptsSet set-titles-string lock-command lock-server
+syn keyword tmuxOptsSet mouse-select-pane message-limit quiet escape-time
+syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg
+syn keyword tmuxOptsSet pane-border-bg pane-border-fg
+syn keyword tmuxOptsSet display-panes-active-colour alternate-screen
+syn keyword tmuxOptsSet detach-on-destroy
+
+syn keyword tmuxOptsSetw monitor-activity aggressive-resize force-width
+syn keyword tmuxOptsSetw force-height remain-on-exit uft8 mode-fg mode-bg
+syn keyword tmuxOptsSetw mode-keys clock-mode-colour clock-mode-style
+syn keyword tmuxOptsSetw xterm-keys mode-attr window-status-attr
+syn keyword tmuxOptsSetw window-status-bg window-status-fg automatic-rename
+syn keyword tmuxOptsSetw main-pane-width main-pane-height monitor-content
+syn keyword tmuxOptsSetw window-status-current-attr window-status-current-bg
+syn keyword tmuxOptsSetw window-status-current-fg mode-mouse synchronize-panes
+syn keyword tmuxOptsSetw window-status-format window-status-current-format
+syn keyword tmuxOptsSetw word-separators
+
+syn keyword tmuxTodo FIXME NOTE TODO XXX contained
+
+syn match tmuxKey              /\(C-\|M-\|\^\)\p/      display
+syn match tmuxNumber           /\d\+/                  display
+syn match tmuxOptions          /\s-\a\+/               display
+syn match tmuxVariable         /\w\+=/                 display
+syn match tmuxVariableExpansion        /\${\=\w\+}\=/          display
+
+syn region tmuxComment start=/#/ end=/$/ contains=tmuxTodo display oneline
+syn region tmuxString  start=/"/ end=/"/ display oneline
+syn region tmuxString  start=/'/ end=/'/ display oneline
+
+hi def link tmuxAction                 Boolean
+hi def link tmuxBoolean                        Boolean
+hi def link tmuxCmds                   Keyword
+hi def link tmuxComment                        Comment
+hi def link tmuxKey                    Special
+hi def link tmuxNumber                 Number
+hi def link tmuxOptions                        Identifier
+hi def link tmuxOptsSet                        Function
+hi def link tmuxOptsSetw               Function
+hi def link tmuxString                 String
+hi def link tmuxTodo                   Todo
+hi def link tmuxVariable               Constant
+hi def link tmuxVariableExpansion      Constant
+
+let b:current_syntax = "tmux"
diff --git a/vim/vim/syntax/vimperator.vim b/vim/vim/syntax/vimperator.vim
new file mode 100644 (file)
index 0000000..ad73c87
--- /dev/null
@@ -0,0 +1,75 @@
+" Vim syntax file
+" Language:         VIMperator configuration file
+" Maintainer:       Doug Kearns <dougkearns@gmail.com>
+" Latest Revision:  2008 August 19
+
+if exists("b:current_syntax")
+  finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+syn include @javascriptTop syntax/javascript.vim
+unlet b:current_syntax
+
+syn keyword vimperatorTodo FIXME NOTE TODO XXX contained
+syn match   vimperatorComment     +".*$+     contains=vimperatorTodo,@Spell
+
+syn region  vimperatorString  start="\z(["']\)" end="\z1" skip="\\\\\|\\\z1" oneline
+
+syn match   vimperatorLineComment +^\s*".*$+ contains=vimperatorTodo,@Spell
+
+syn keyword vimperatorCommand ab[breviate] ab[clear] addo[ns] au[tocmd] b[uffer] ba[ck] bd[elete] beep bma[rk] bmarks buffers
+    \ bun[load] bw[ipeout] ca[bbrev] cabc[lear] cd cuna[bbrev] cm[ap] cmapc[lear] cno[remap] comc[lear] com[mand] cu[nmap]
+    \ delbm[arks] delc[ommand] delmac[ros] delm[arks] delqm[arks] dia[log] dl downl[oads] e[dit] ec[ho] echoe[rr] em[enu]
+    \ exe[cute] exu[sage] files fo[rward] fw h[elp] ha[rdcopy] hist[ory] hs ia[bbrev] iabc[lear] im[ap] imapc[lear] ino[remap]
+    \ iuna[bbrev] iu[nmap] javas[cript] ju[mps] js let ls macros ma[rk] map mapc[lear] marks mkv[imperatorrc] no[remap]
+    \ noh[lsearch] norm[al] o[pen] pa[geinfo] pagest[yle] pc[lose] pl[ay] pref[erences] prefs pwd q[uit] qa[ll] qma[rk] qmarks
+    \ quita[ll] re[draw] re[load] reloada[ll] res[tart] run sav[eas] sb[ar] sb[open] sbcl[ose] se[t] setg[lobal] setl[ocal]
+    \ sideb[ar] so[urce] st[op] tN[ext] t[open] tab tabd[uplicate] tabN[ext] tabc[lose] tabe[dit] tabfir[st] tabl[ast] tabm[ove]
+    \ tabn[ext] tabnew tabo[nly] tabopen tabp[revious] tabr[ewind] tabs time tn[ext] tp[revious] u[ndo] una[bbreviate] undoa[ll]
+    \ unl[et] unm[ap] ve[rsion] vie[wsource] viu[sage] w[rite] wc[lose] win[open] winc[lose] wine[dit] wo[pen] wqa[ll] wq xa[ll]
+    \ zo[om]
+       \ contained
+
+syn match vimperatorCommand "!" contained
+
+" FIXME
+syn match vimperatorCommandWrapper "\%(^\s*:\=\)\@<=\%(!\|\h\w*\>\)" contains=vimperatorCommand
+
+syn region vimperatorSet matchgroup=vimperatorCommand start="\%(^\s*:\=\)\@<=\<set\=\>" end="$" keepend oneline contains=vimperatorOption
+syn keyword vimperatorOption activate act activelinkfgcolor alfc activelinkbgcolor albc complete cpt defsearch ds editor
+    \ extendedhinttags eht focuscontent fc nofocuscontent nofc fullscreen fs nofullscreen nofs guioptions go hintmatching hm
+    \ hintstyle hs hinttags ht hinttimeout hto history hi hlsearch hls nohlsearch nohls hlsearchstyle hlss incsearch is
+    \ noincsearch nois ignorecase ic noignorecase noic insertmode im noinsertmode noim laststatus ls linkbgcolor lbc linkfgcolor
+    \ lfc linksearch lks nolinksearch nolks more newtab nextpattern nomore pageinfo pa popups pps preload nopreload previewheight
+    \ pvh previouspattern online noonline scroll scr shell sh shellcmdflag shcf showmode smd noshowmode nosmd showstatuslinks ssli
+    \ showtabline stal smartcase scs nosmartcase noscs suggestengines titlestring usermode um nousermode noum urlseparator verbose
+    \ vbs visualbell vb novisualbell novb visualbellstyle wildmode wim wildoptions wop wordseparators wsp
+    \ contained
+
+syn region vimperatorJavascript start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=" end="$" contains=@javascriptTop keepend oneline
+syn region vimperatorJavascript matchgroup=vimperatorJavascriptDelimiter
+       \ start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=<<\z(\h\w*\)"hs=s+2 end="^\z1$" contains=@javascriptTop fold
+
+syn region vimperatorMap matchgroup=vimperatorCommand start="\%(^\s*:\=\)\@<=\<map\>" end="$" keepend oneline contains=vimperatorKeySym
+
+syn match vimperatorKeySym "<[0-9A-Za-z-]\+>"
+
+" Note: match vim.vim highlighting groups
+hi def link vimperatorCommand                      Statement
+hi def link vimperatorComment                      Comment
+hi def link vimperatorJavascriptDelimiter      Delimiter
+hi def link vimperatorKeySym                       Special
+hi def link vimperatorLineComment                  Comment
+hi def link vimperatorOption                       PreProc
+hi def link vimperatorString                       String 
+hi def link vimperatorTodo                  Todo
+
+let b:current_syntax = "vimperator"
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim: tw=130 et ts=4 sw=4:
diff --git a/vim/vimrc b/vim/vimrc
new file mode 100644 (file)
index 0000000..e8f19ff
--- /dev/null
+++ b/vim/vimrc
@@ -0,0 +1,1112 @@
+" Vim main configuration file.
+
+" Copyright (C) 2008-2016  Simon Ruderich
+"
+" This file is free software: you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation, either version 3 of the License, or
+" (at your option) any later version.
+"
+" This file 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 General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+
+" EDITOR SETTINGS
+
+" Save 'runtimepath' in case it was changed by the system's configuration
+" files. Also save 'diff' as set all& resets it; but somehow later (after
+" sourcing the vimrc - for example in a VimEnter autocmd) it gets
+" automagically restored to the correct value. Not sure what exactly Vim is
+" doing there.
+if has('eval')
+    let s:save_runtimepath = &runtimepath
+    let s:save_diff = &diff
+endif
+" Reset all options (except 'term', 'lines' and 'columns'). This makes sure a
+" system wide configuration file doesn't change default values.
+set all&
+" And restore it after all other options were reset.
+if has('eval')
+    let &runtimepath = s:save_runtimepath
+    let &diff = s:save_diff
+    unlet s:save_runtimepath
+    unlet s:save_diff
+endif
+
+" Make sure Vim (and not Vi) settings are used.
+set nocompatible
+
+" Disallow :autocmd, shell and write commands in .vimrc and .exrc files in the
+" current directory. Only used if 'exrc' is enabled (off by default),
+" precaution just in case somebody enables 'exrc'.
+set secure
+
+" Try to use pipes instead of temporary files. Prevents some auto commands
+" from running for temporary files but also prevents the file's content to be
+" written to disk.
+set noshelltemp
+
+" Use UTF-8 for all internal data (buffers, registers, etc.). This doesn't
+" affect reading files in different encodings, see 'fileencodings' for that.
+set encoding=utf-8
+
+" Load my scripts from ~/.vim (my scripts) and ~/.vim/runtime (checkout of Vim
+" runtime files) if available.
+set runtimepath-=~/.vim
+set runtimepath^=~/.vim,~/.vim/runtime
+
+" Don't store swap files in the same directory as the edited file, but only if
+" we have a "safe" writable directory available.
+if filewritable('~/.tmp') == 2 || filewritable('~/tmp') == 2
+    set directory-=.
+endif
+" But store them in ~/.tmp or ~/tmp (already set by default) if available.
+set directory^=~/.tmp
+" Never use /tmp which gets cleaned on reboot.
+set directory-=/tmp
+
+" Disable modelines as they may cause security problems. Instead use
+" securemodelines (Vim script #1876).
+set nomodeline
+
+" Complete to longest common string (list:longest) and then complete all full
+" matches after another (full). Thanks to pbrisbin
+" (http://pbrisbin.com:8080/dotfiles/vimrc).
+set wildmode=list:longest,full
+" Ignore case when completing files/directories.
+if exists('+wildignorecase')
+    set wildignorecase
+endif
+
+" Ignore files with the following extensions because I almost never want to
+" edit them in Vim (specifying them manually still works of course).
+set wildignore=
+" C
+set wildignore+=*.o,*.d,*.so
+" Java
+set wildignore+=*.class
+" LaTeX
+set wildignore+=*.aux,*.log,*.out,*.toc,*.pdf
+" Python
+set wildignore+=*.pyc
+
+" Show completion menu even if only one entry matches.
+if exists('+completeopt')
+    set completeopt+=menuone
+endif
+
+" Increase history of executed commands (:) and search patterns (/).
+set history=1000
+
+" Increase number of possible undos.
+set undolevels=1000
+
+" Remember marks (including the last cursor position) for more files. ^= is
+" necessary because 'viminfo' is parsed from the beginning and the first match
+" is used.
+if has('viminfo')
+    set viminfo^='1000
+endif
+
+" Use strong encryption if possible, also used for swap/undo files.
+if exists('+cryptmethod')
+    set cryptmethod=blowfish
+endif
+
+" Clear all vimrc-related autocmds. Has to be done here as the vimrc augroup
+" is used multiple times. Necessary to support reloading the vimrc.
+if has('autocmd')
+    augroup vimrc
+        autocmd!
+    augroup END
+endif
+
+
+" HELPER FUNCTIONS
+
+if has('eval')
+" Check if the given syntax group is available. Thanks to bairui in #vim on
+" Freenode (2012-02-19 01:15 CET) for the try/catch silent highlight idea.
+    function! s:HasSyntaxGroup(group)
+        try
+            execute 'silent highlight ' . a:group
+        " \a = [A-Za-z]
+        catch /^Vim\%((\a\+)\)\=:E411/ " 'highlight group not found'
+            return 0
+        endtry
+        return 1
+    endfunction
+
+" Check if the given Vim version and patch is available.
+    function! s:HasVersionAndPatch(version, patch)
+        return v:version > a:version
+            \ || (v:version == a:version && has('patch' . a:patch))
+    endfunction
+endif
+
+
+" TERMINAL SETTINGS
+
+" Also enable fast terminal mode in GNU screen and tmux, but not for SSH
+" connections.
+if &term =~# '^screen' && !exists('$SSH_CONNECTION')
+    set ttyfast
+endif
+
+
+" EDIT SETTINGS
+
+" Enable automatic file detection, plugin and indention support.
+if has('autocmd')
+    filetype off " necessary for pathogen to force a reload of ftplugins
+    filetype plugin indent on
+endif
+
+" Use UTF-8 file encoding for all files. Automatically recognize latin1 in
+" existing files.
+set fileencodings=utf-8,latin1
+
+" Always use unix line-endings for new files. DOS line endings in existing
+" files are recognized.
+set fileformats=unix,dos
+
+" Wrap text after 78 characters.
+set textwidth=78
+
+" Set tabs to 4 spaces, use softtabs.
+set shiftwidth=4
+set softtabstop=4
+set expandtab
+" When < and > is used indent/deindent to the next 'shiftwidth' boundary.
+set shiftround
+" Use the default value for real tabs.
+set tabstop=8
+
+" Enable auto indention.
+set autoindent
+
+" When joining lines only add one space after a sentence.
+set nojoinspaces
+
+" Allow backspacing over autoindent and line breaks.
+set backspace=indent,eol
+
+" Start a comment when hitting enter after a commented line (r) and when using
+" o or O around a commented line (o).
+set formatoptions+=ro
+" Don't break a line if was already longer then 'textwidth' when insert mode
+" started.
+set formatoptions+=l
+" Remove comment leader when joining lines where it makes sense.
+if s:HasVersionAndPatch(703, 541)
+    set formatoptions+=j
+endif
+
+" Allow virtual editing (cursor can be positioned anywhere, even when there is
+" no character) in visual block mode.
+set virtualedit=block
+
+" Already display matches while typing the search command. This makes spotting
+" typos easy and searching faster.
+set incsearch
+
+" Activate syntax folding.
+if has('folding')
+    set foldmethod=syntax
+    " Only use fold column if we have enough space (for example not in a
+    " (virtual) terminal which has only 80 columns).
+    if &columns > 80
+        set foldcolumn=2
+    endif
+    set foldlevel=99 " no closed folds at default, 'foldenable' would disable
+                     " folding which is not what I want
+    " Don't open folds for block movements like '(', '{', '[[', '[{', etc.
+    set foldopen-=block
+endif
+
+" Only check case if the searched word contains a capital character.
+set ignorecase
+set smartcase
+
+" Activate spell checking, use English as default.
+if exists('+spell') && has('syntax')
+    " But not when diffing because spell checking is distracting in this case.
+    if !&diff
+        set spell
+    endif
+    set spelllang=en_us
+endif
+
+" Allow buffers with changes to be hidden. Very important for efficient
+" editing with multiple buffers. Prevents the "E37: No write since last change
+" (add ! to override)" warning when switching modified buffers.
+set hidden
+
+" When splitting vertically put the new window right of the current one.
+if has('vertsplit')
+    set splitright
+endif
+
+
+" DISPLAY SETTINGS
+
+" Use a dark background. Doesn't change the background color, only sets text
+" colors for a dark terminal.
+set background=dark
+
+" Use my color scheme if 256 colors are available.
+if &t_Co == 256 || has('gui_running')
+    colorscheme simon
+endif
+
+" Display line numbers.
+set number
+" But use as little space as possible for the numbers column. Thanks to James
+" Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary).
+if exists('+numberwidth')
+    set numberwidth=1
+endif
+" Display the ruler with current line/file position. If 'statusline' is used,
+" then this only affects <C-G>.
+set ruler
+" Display partial commands in the status line.
+set showcmd
+
+" Don't redraw screen when executing macros; increases speed. Thanks to James
+" Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary).
+set lazyredraw
+
+" Visualize the line the cursor is currently in.
+if exists('+cursorline')
+    set cursorline
+endif
+
+" Highlight all matches on the screen when searching. Use <C-L> (see below) to
+" remove the highlighting until the next search.
+set hlsearch
+
+" Display some special characters.
+set list
+set listchars=
+" Display tabs as ">--------".
+set listchars+=tab:>-
+" Display trailing whitespace as "-".
+set listchars+=trail:-
+" Display markers for long lines when wrapping is disabled.
+set listchars+=extends:>,precedes:<
+" Display non-breakable space as "!".
+if v:version >= 700
+    set listchars+=nbsp:!
+endif
+
+" Don't draw the vertical split separator by using space as character. Thanks
+" to scp1 in #vim on Freenode (2012-06-16 16:12 CEST) for the idea to use a
+" non-breakable space. But a simple space works as well, as long as the
+" current color scheme is not reset.
+if has('windows') && has('folding')
+    set fillchars+=vert:\  " comment to prevent trailing whitespace
+endif
+
+if has('statusline')
+    " Always display the status line even if there is only one window.
+    set laststatus=2
+
+    " If there's more than one buffer return "/<nr>" (e.g. "/05") where <nr>
+    " is the highest buffer number, otherwise return nothing. Used in
+    " 'statusline' to get an overview of available buffer numbers.
+    function! s:StatuslineBufferCount()
+        let l:bufnr = bufnr('$')
+        if l:bufnr > 1
+            let l:result = '/'
+            if exists('*printf')
+                let l:result .= printf('%02d', l:bufnr)
+            else
+                " Older Vims don't have printf() (and no .= either). Emulate
+                " "%02d".
+                if l:bufnr < 10
+                    let l:result = l:result . '0'
+                endif
+                let l:result = l:result . l:bufnr
+            endif
+            return l:result
+        else
+            return ''
+        endif
+    endfunction
+
+    " Like %f but use relative filename if it's shorter than the absolute path
+    " (e.g. '../../file' vs. '~/long/path/to/file'). fnamemodify()'s ':.' is
+    " not enough because it doesn't create '../'s.
+    function! s:StatuslineRelativeFilename()
+        " Display only filename for help files.
+        if &buftype == 'help'
+            return expand('%:t')
+        endif
+        " Special case for scratch files.
+        if &buftype == 'nofile'
+            return '[Scratch]'
+        endif
+
+        let l:path = expand('%')
+        " No file.
+        if l:path == ''
+            return '[No Name]'
+        endif
+        " Path is already relative, nothing to do.
+        if stridx(l:path, '/') != 0
+            return l:path
+        endif
+
+        " Absolute path to this file.
+        let l:path = expand('%:p')
+        " Shortened path to this file, thanks to bairui in #vim on Freenode
+        " (2012-06-23 00:54) for the tip to use fnamemodify(). This is what
+        " Vim normally uses as %f (minus some exceptions).
+        let l:original_path = fnamemodify(l:path, ':~')
+        " Absolute path to the current working directory.
+        let l:cwd = getcwd()
+
+        " Working directory completely contained in path, replace it with a
+        " relative path. Happens for example when opening a file with netrw.
+        " %f displays this as absolute path, but we want a relative path of
+        " course.
+        if stridx(l:path, l:cwd) == 0
+            return strpart(l:path, strlen(l:cwd) + 1)
+        endif
+
+        let l:path_list = split(l:path, '/')
+        let l:cwd_list  = split(l:cwd,  '/')
+
+        " Remove the common path.
+        while l:path_list[0] == l:cwd_list[0]
+            call remove(l:path_list, 0)
+            call remove(l:cwd_list,  0)
+        endwhile
+
+        " Add as many '..' as necessary for the relative path and join the
+        " path. Thanks to Raimondi in #vim on Freenode (2012-06-23 01:13) for
+        " the hint to use repeat() instead of a loop.
+        let l:path = repeat('../', len(l:cwd_list)) . join(l:path_list, '/')
+
+        " Use the shorter path, either relative or absolute.
+        if strlen(l:path) < strlen(l:original_path)
+            return l:path
+        else
+            return l:original_path
+        endif
+    endfunction
+
+    " Display unexpected 'fileformat', 'fileencoding' and 'bomb' settings.
+    function! s:StatuslineFileFormat()
+        if &fileformat != 'unix'
+            return '[' . &fileformat . ']'
+        else
+            return ''
+        endif
+    endfunction
+    function! s:StatuslineFileEncoding()
+        if &fileencoding != '' && &fileencoding != 'utf-8'
+                \ && &filetype != 'help'
+            return '[' . &fileencoding . ']'
+        else
+            return ''
+        endif
+    endfunction
+    function! s:StatuslineFileBOMB()
+        if exists('+bomb') && &bomb
+            return '[BOM]'
+        else
+            return ''
+        endif
+    endfunction
+
+    " Return current syntax group in brackets or nothing if there's none.
+    function! s:StatuslineSyntaxGroup()
+        let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
+        if l:group != ''
+            return '[' . l:group . '] '
+        else
+            return ''
+        endif
+    endfunction
+
+    " Short function names to make 'statusline' more readable.
+    function! SBC()
+        return s:StatuslineBufferCount()
+    endfunction
+    function! SRF()
+        return s:StatuslineRelativeFilename()
+    endfunction
+    function! SFF()
+        return s:StatuslineFileFormat()
+    endfunction
+    function! SFE()
+        return s:StatuslineFileEncoding()
+    endfunction
+    function! SFB()
+        return s:StatuslineFileBOMB()
+    endfunction
+    function! SSG()
+        return s:StatuslineSyntaxGroup()
+    endfunction
+
+    set statusline=
+    " on the left
+    set statusline+=%02n              " buffer number
+    set statusline+=%{SBC()}          " highest buffer number
+    set statusline+=:
+    if has('modify_fname') && v:version >= 700 " some functions need 7.0
+        set statusline+=%{SRF()}      " path to current file
+    else
+        set statusline+=%f            " path to current file in buffer
+    endif
+    set statusline+=\                 " space after path
+    set statusline+=%h                " [help] if buffer is help file
+    set statusline+=%w                " [Preview] if buffer is preview buffer
+    set statusline+=%m                " [+] if buffer was modified,
+                                      " [-] if 'modifiable' is off
+    set statusline+=%r                " [RO] if buffer is read only
+    if v:version >= 700               " %#..# needs 7.0
+        set statusline+=%#Error#      " display warnings
+        set statusline+=%{SFF()}      "   - unexpected file format
+        set statusline+=%{SFE()}      "   - unexpected file encoding
+        set statusline+=%{SFB()}      "   - unexpected file byte order mask
+        set statusline+=%##           " continue with normal colors
+    endif
+
+    " on the right
+    set statusline+=%=                " right align
+    set statusline+=0x%-8B\           " current character under cursor as hex
+    set statusline+=%-12.(%l,%c%V%)\  " line number (%l),
+                                      " column number (%c),
+                                      " virtual column number if different
+                                      "                       than %c (%V)
+    set statusline+=%P                " position in file in percent
+endif
+
+
+" MAPPINGS (except for plugins, see PLUGIN SETTINGS below)
+
+" noremap is used to make sure the right side is executed as is and can't be
+" modified by a plugin or other settings. Except for <Nop> which isn't
+" affected by mappings.
+
+" Easy way to exit insert mode (jj is too slow).
+inoremap jk <Esc>
+" Also for command mode, thanks to http://github.com/mitechie/pyvim
+" (2010-10-15).
+cnoremap jk <C-C>
+" And fix my typos ...
+inoremap JK <Esc>
+inoremap Jk <Esc>
+inoremap jK <Esc>
+cnoremap JK <C-C>
+cnoremap Jk <C-C>
+cnoremap jK <C-C>
+
+" Disable arrow keys for all modes except command modes. Thanks to James Vega
+" (http://git.jamessan.com/?p=etc/vim.git;a=summary).
+map <Right>  <Nop>
+map <Left>   <Nop>
+map <Up>     <Nop>
+map <Down>   <Nop>
+imap <Right> <Nop>
+imap <Left>  <Nop>
+imap <Up>    <Nop>
+imap <Down>  <Nop>
+" Also disable arrow keys in command mode, use <C-P>/<C-N> as replacement (see
+" below).
+cmap <Up>    <Nop>
+cmap <Down>  <Nop>
+cmap <Right> <Nop>
+cmap <Left>  <Nop>
+
+" Use <C-P>/<C-N> as replacement for <Up>/<Down> in command mode. Thanks to
+" abstrakt and grayw in #vim on Freenode (2010-04-12 21:20 CEST).
+cnoremap <C-P> <Up>
+cnoremap <C-N> <Down>
+
+" Use :tjump to lookup tags (instead of :tag) which lists all available tags
+" if there's more than one match. This is really helpful in larger projects
+" where tags may occur multiple times.
+nnoremap <C-]> g<C-]>
+
+if has('eval')
+" Don't move the cursor to the first column for certain scroll commands (<C-F,
+" <C-B>, <C-D>, <C-U>). Thanks to jamessan in #vim on Freenode (2011-08-31
+" 02:27 CEST) for the 'nostartofline' tip. But I can't use 'nostartofline'
+" directly because it also enables that feature for other commands which I
+" don't want.
+
+    " Set 'nostartofline' for a single movement.
+    function! s:TemporaryNostartofline(movement)
+        let l:startofline = &startofline
+        set nostartofline
+        execute 'normal! ' . a:movement
+        let &startofline = l:startofline
+    endfunction
+
+    " Thanks to fow in #vim on Freenode (2012-02-16 15:38 CET) for the idea to
+    " use "<Bslash><Lt>"; Vim documentation reference: :help <>.
+    nnoremap <silent> <C-F>
+        \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-F>")<CR>
+    nnoremap <silent> <C-B>
+        \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-B>")<CR>
+    nnoremap <silent> <C-D>
+        \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-D>")<CR>
+    nnoremap <silent> <C-U>
+        \ :call <SID>TemporaryNostartofline("<Bslash><Lt>C-U>")<CR>
+endif
+
+" Let Y yank to the end of the line, similar to D and C. Use yy if you want to
+" yank a line. This fixes a weird inconsistency in Vi(m).
+nnoremap Y y$
+
+" Write before suspending, thanks to deryni in #vim on Freenode (2011-05-09
+" 20:02 CEST). To suspend without saving either unmap this or use :stop<CR>.
+" Only the current buffer is written, thus switching to another buffer works
+" too.
+nnoremap <silent> <C-Z> :update<CR>:stop<CR>
+
+" 2<C-G> gives more verbose information, use it by default. Thanks to NCS_One
+" in #vim on Freenode (2011-08-15 00:17 CEST).
+nnoremap <C-G> 2<C-G>
+
+" Use <Space> to move down a page and - to move up one like in mutt. Don't use
+" nnoremap so the <C-F>/<C-B> 'nostartofline' fix (see above) works.
+nmap <Space> <C-F>
+nmap - <C-B>
+
+" Go to next and previous buffer. Thanks to elik in #vim on Freenode
+" (2010-05-16 18:38 CEST) for this idea.
+nnoremap <silent> gb :bnext<CR>
+nnoremap <silent> gB :bprevious<CR>
+if has('eval')
+    " But when starting again at the first buffer, print a warning which
+    " reminds me that I've already seen that buffer.
+    function! s:NextBuffer()
+        " Are we currently on the last buffer and moving to the first?
+        let l:last_buffer = 0
+        if bufnr('%') == bufnr('$') && bufnr('$') > 1
+            let l:last_buffer = 1
+        endif
+
+        " Go to the next buffer.
+        if !l:last_buffer
+            bnext
+
+        " Go to the first buffer, silent is necessary or the following message
+        " won't be displayed because it's overwritten by the status message
+        " displayed when entering a buffer.
+        else
+            silent bnext
+
+            echohl WarningMsg
+            echo 'Starting again at first buffer.'
+            echohl None
+        endif
+    endfunction
+    nnoremap <silent> gb :call <SID>NextBuffer()<CR>
+endif
+
+" Fast access to buffers.
+nnoremap <silent> <Leader>1 :1buffer<CR>
+nnoremap <silent> <Leader>2 :2buffer<CR>
+nnoremap <silent> <Leader>3 :3buffer<CR>
+nnoremap <silent> <Leader>4 :4buffer<CR>
+nnoremap <silent> <Leader>5 :5buffer<CR>
+nnoremap <silent> <Leader>6 :6buffer<CR>
+nnoremap <silent> <Leader>7 :7buffer<CR>
+nnoremap <silent> <Leader>8 :8buffer<CR>
+nnoremap <silent> <Leader>9 :9buffer<CR>
+nnoremap <silent> <Leader>0 :10buffer<CR>
+
+" Use real tabs instead of soft tabs.
+if has('eval')
+" Switch from soft tabs to real tabs.
+    function! s:UseTabs()
+        setlocal noexpandtab shiftwidth=8 softtabstop=8
+    endfunction
+    nnoremap <silent> <Leader>t :call <SID>UseTabs()<CR>
+endif
+" Enable "verbatim" mode. Used to view files with long lines or without syntax
+" coloring. 'list' is not changed, see next mapping.
+nnoremap <silent> <Leader>v :setlocal nowrap nospell synmaxcol=0<CR>
+                          \ :2match<CR>
+" Toggle 'list'.
+nnoremap <silent> <Leader>l :set invlist<CR>
+
+" Make last active window the only window. Similar to <C-W> o.
+nnoremap <C-W>O <C-W>p<C-W>o
+
+" Maps to change spell language between English and German and disable spell
+" checking.
+if exists('+spell')
+    nnoremap <silent> <Leader>sn :set nospell<CR>
+    nnoremap <silent> <Leader>se :set spell spelllang=en_us<CR>
+    nnoremap <silent> <Leader>sd :set spell spelllang=de_de<CR>
+" If no spell support is available, these mappings do nothing.
+else
+    nmap <Leader>sn <Nop>
+    nmap <Leader>se <Nop>
+    nmap <Leader>sd <Nop>
+endif
+
+if has('eval')
+" * and # for selections in visual mode. Thanks to
+" http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html
+" and all nerds involved (godlygeek, strull in #vim on Freenode).
+    function! s:VSetSearch()
+        let l:temp = @@ " unnamed register
+        normal! gvy
+        " Added \C to force 'noignorecase' while searching the current visual
+        " selection. I want to search for the exact string in this case.
+        let @/ = '\C' . '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
+        let @@ = l:temp
+    endfunction
+    vnoremap * :<C-U>call <SID>VSetSearch()<CR>//<CR>
+    vnoremap # :<C-U>call <SID>VSetSearch()<CR>??<CR>
+
+" Use 'noignorecase' for * and #. See comment in s:VSetSearch() for details.
+" Thanks to the writers of s:VSetSearch(), see above.
+    function! s:NSetSearch()
+        let l:cword = expand('<cword>')
+        let l:regex = substitute(escape(l:cword, '\'), '\n', '\\n', 'g')
+        let @/ = '\C\V'. '\<' . l:regex . '\>'
+    endfunction
+    nnoremap * :call <SID>NSetSearch()<CR>//<CR>
+    nnoremap # :call <SID>NSetSearch()<CR>??<CR>
+endif
+
+" I often type "W" instead of "w" when trying to save a file. Fix my mistake.
+" Thanks to Tony Mechelynck <antoine.mechelynck@gmail.com> from the Vim
+" mailing list for the commands.
+if v:version < 700
+    cnoreabbrev W w
+    cnoreabbrev Wa wa
+    cnoreabbrev Wq wq
+    cnoreabbrev Wqa wqa
+else
+    cnoreabbrev <expr> W
+        \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'w' : 'W')
+    cnoreabbrev <expr> Wa
+        \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wa' : 'Wa')
+    cnoreabbrev <expr> Wq
+        \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'wq' : 'Wq')
+    cnoreabbrev <expr> Wqa
+        \ ((getcmdtype() == ':' && getcmdpos() <= 4) ? 'wqa' : 'Wqa')
+endif
+" Also fix my typo with "Q".
+if v:version < 700
+    cnoreabbrev Q q
+    cnoreabbrev Qa qa
+else
+    cnoreabbrev <expr> Q
+        \ ((getcmdtype() == ':' && getcmdpos() <= 2) ? 'q' : 'Q')
+    cnoreabbrev <expr> Qa
+        \ ((getcmdtype() == ':' && getcmdpos() <= 3) ? 'qa' : 'Qa')
+endif
+
+" In case 'hlsearch' is used disable it with <C-L>. Thanks to frogonwheels and
+" vimgor (bot) in #vim on Freenode (2010-03-30 05:58 CEST).
+nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
+
+" <C-U> in insert mode deletes a lot, break undo sequence before deleting the
+" line so the change can be undone. Thanks to the vimrc_example.vim file in
+" Vim's source.
+inoremap <C-U> <C-G>u<C-U>
+" Same for <C-@> (insert previously inserted text and leave insert mode).
+inoremap <C-@> <C-G>u<C-@>
+" And for <C-A> (insert previously inserted text).
+inoremap <C-A> <C-G>u<C-A>
+" And for <C-W> (delete word before cursor).
+inoremap <C-W> <C-G>u<C-W>
+
+if has('eval')
+" New text-objects ii and ai to work on text with the same indentation. Thanks
+" to http://vim.wikia.com/index.php?title=Indent_text_object&oldid=27126
+" (visited on 2011-11-19).
+    onoremap <silent> ai :<C-U>call <SID>IndTxtObj(0)<CR>
+    onoremap <silent> ii :<C-U>call <SID>IndTxtObj(1)<CR>
+    vnoremap <silent> ai :<C-U>call <SID>IndTxtObj(0)<CR><Esc>gv
+    vnoremap <silent> ii :<C-U>call <SID>IndTxtObj(1)<CR><Esc>gv
+
+    function! s:IndTxtObj(inner)
+        let curline = line(".")
+        let lastline = line("$")
+        let i = indent(line(".")) - &shiftwidth * (v:count1 - 1)
+        let i = i < 0 ? 0 : i
+        if getline(".") !~ "^\\s*$"
+            let p = line(".") - 1
+            let nextblank = getline(p) =~ "^\\s*$"
+            while p > 0
+                    \ && ((i == 0 && !nextblank)
+                        \ || (i > 0 && ((indent(p) >= i
+                            \ && !(nextblank && a:inner))
+                            \ || (nextblank && !a:inner))))
+                -
+                let p = line(".") - 1
+                let nextblank = getline(p) =~ "^\\s*$"
+            endwhile
+            normal! 0V
+            call cursor(curline, 0)
+            let p = line(".") + 1
+            let nextblank = getline(p) =~ "^\\s*$"
+            while p <= lastline
+                    \ && ((i == 0 && !nextblank)
+                        \ || (i > 0 && ((indent(p) >= i
+                            \ && !(nextblank && a:inner))
+                            \ || (nextblank && !a:inner))))
+                +
+                let p = line(".") + 1
+                let nextblank = getline(p) =~ "^\\s*$"
+            endwhile
+            normal! $
+        endif
+    endfunction
+endif
+
+
+" ABBREVIATIONS
+
+" Fix some of my spelling mistakes (German).
+inoreabbrev relle reelle
+inoreabbrev reele reelle
+" Fix some of my spelling mistakes (English).
+inoreabbrev completly completely
+
+
+" SYNTAX SETTINGS
+
+" Activate syntax coloring.
+if has('syntax')
+    " But only if it wasn't already active. Prevents breaking the syntax
+    " coloring when reloading the vimrc. Thanks to johnLate for the idea.
+    if !exists('g:syntax_on')
+        syntax enable
+    endif
+
+" Don't highlight more than 500 columns as I normally don't have that long
+" lines and they slow down syntax coloring. Thanks to Derek Wyatt
+" (http://www.derekwyatt.org/vim/the-vimrc-file/).
+    if exists('+synmaxcol')
+        set synmaxcol=500
+    endif
+
+" Use (limited) syntax based omni completion if no other omni completion is
+" available. Taken from :help ft-syntax-omni.
+    if has('autocmd') && exists('+omnifunc')
+        augroup vimrc
+            autocmd FileType *
+                \ if &omnifunc == '' |
+                \     setlocal omnifunc=syntaxcomplete#Complete |
+                \ endif
+        augroup END
+    endif
+
+" Function to enable all custom highlights. Necessary as highlights are
+" window-local and thus must be set for each new window.
+    function! s:CustomSyntaxHighlights()
+        " Not the first time called, nothing to do.
+        if exists('w:vimrc_syntax_run')
+            return
+        endif
+        let w:vimrc_syntax_run = 1
+
+" Highlight lines longer than 78 characters. Thanks to Tony Mechelynck
+" <antoine.mechelynck@gmail.com> from the Vim mailing list. It can easily be
+" disabled when necessary with :2match (in Vim >= 700).
+        if !&diff && exists(':2match')
+            " Use ColorColumn for overlong lines if available and my color
+            " scheme is used.
+            if &t_Co == 256 && s:HasSyntaxGroup('ColorColumn')
+                2match ColorColumn /\%>78v./
+            else
+                2match Todo /\%>78v./
+            endif
+        elseif !&diff
+            match Todo /\%>78v./
+        endif
+
+        if exists('*matchadd')
+" Highlight some important keywords in all documents.
+            let l:todos = ['TODO', 'XXX', 'FIXME', 'NOTE',
+                         \ 'CHANGED', 'REMOVED', 'DELETED']
+            " Compatibility fix for Vim 6.4 which can't parse for in functions
+            " (without function it's ignored).
+            execute '  for l:x in l:todos'
+                  \ '|     call matchadd("Todo", l:x)'
+                  \ '| endfor'
+
+" Highlight Unicode whitespace which is no normal whitespace (0x20).
+            let l:spaces = ['00a0', '1680', '180e', '2000', '2001', '2002',
+                          \ '2003', '2004', '2005', '2006', '2007', '2008',
+                          \ '2009', '200a', '200b', '200c', '200d', '202f',
+                          \ '205f', '2060', '3000', 'feff']
+            " Compatibility fix for Vim 6.4. Escape \ inside the " string or
+            " it won't work!
+            execute '  for l:x in l:spaces'
+                  \ '|     call matchadd("Error", "\\%u" . l:x)'
+                  \ '| endfor'
+
+" Special highlight for tabs to reduce their visibility in contrast to other
+" SpecialKey characters (e.g. ^L).
+            if &t_Co == 256 && s:HasSyntaxGroup('specialKeyTab')
+                call matchadd('specialKeyTab', '\t')
+            endif
+        endif
+    endfunction
+" Enable highlights for the current and all new windows. Thanks to bairui in
+" #vim on Freenode (2012-04-01 00:22 CEST) for the WinEnter suggestion.
+    call s:CustomSyntaxHighlights()
+    if has('autocmd')
+        augroup vimrc
+            autocmd WinEnter * call s:CustomSyntaxHighlights()
+        augroup END
+    endif
+
+" Settings for specific filetypes.
+
+    " C
+    let g:c_no_if0_fold = 1 " fix weird double fold in #if0 in recent versions
+    " Haskell
+    let g:hs_highlight_delimiters = 1
+    let g:hs_highlight_boolean = 1
+    let g:hs_highlight_types = 1
+    let g:hs_highlight_more_types = 1
+    " Java
+    let g:java_highlight_java_lang_ids = 1 " color java.lang.* identifiers
+    " Perl
+    let g:perl_fold = 1
+    let g:perl_fold_blocks = 1
+    let g:perl_nofold_packages = 1
+    let g:perl_include_pod = 1 " syntax coloring for PODs
+    " PHP
+    let g:php_folding = 3    " fold functions
+    let g:php_short_tags = 0 " no short tags (<? .. ?>), not always usable
+    let g:php_sql_query = 1  " highlight SQL queries in strings
+    " Python
+    let g:python_highlight_all = 1
+    " Shell
+    let g:sh_noisk = 1        " don't add . to 'iskeyword'
+    let g:sh_is_posix = 1     " POSIX shell (e.g. dash) is compatible enough
+    let g:is_posix = 1        " POSIX shell (e.g. dash) is compatible enough
+    let g:sh_fold_enabled = 7 " functions (1), heredoc (2) and if/do/for (4)
+    " Vim
+    let g:vimsyn_embed = 0      " don't highlight embedded languages
+    let g:vimsyn_folding = 'af' " folding for autogroups (a) and functions (f)
+    " XML
+    let g:xml_syntax_folding = 1
+endif
+
+
+" PLUGIN SETTINGS
+
+if has('eval')
+" Use pathogen which allows one 'runtimepath' entry per plugin. This makes
+" installing/removing/updating plugins simple. (Used for plugins with more
+" than one file.) Ignore errors in case pathogen is not installed.
+    if v:version >= 700
+        silent! execute 'call pathogen#infect()'
+    endif
+
+" Settings for securemodelines.
+    " Only allow items I need (also includes spl which is not enabled by
+    " default).
+    if v:version >= 700 " need lists
+        let g:secure_modelines_allowed_items = ['ft', 'spl', 'fdm',
+                                              \ 'sw', 'sts', 'noet']
+    endif
+
+" Settings for gnupg.
+    " Don't use temporary files for sensitive data.
+    let g:GPGUsePipes = 1
+
+" Settings for the NERD commenter.
+    " Don't create any mappings I don't want to use.
+    let g:NERDCreateDefaultMappings = 0
+    " Map toggle comment.
+    nmap <Leader><Leader> <Plug>NERDCommenterToggle
+
+" XPTemplate settings.
+    " Try to maintain snippet rendering even after editing outside of a
+    " snippet.
+    let g:xptemplate_strict = 0
+    " Don't complete any braces automatically.
+    let g:xptemplate_brace_complete = 0
+    " Only highlight the current placeholder.
+    let g:xptemplate_highlight = 'current'
+
+" CtrlP settings.
+    " Don't manage the working directory (the default setting is too slow for
+    " me).
+    let g:ctrlp_working_path_mode = 0
+
+    " Path to cache directory. I prefer to keep generated files as local as
+    " possible.
+    let g:ctrlp_cache_dir = $HOME . '/.vim/cache/ctrlp'
+    " Permanent cache, cleared by a crontab entry. Use <F5> to update the
+    " cache manually.
+    let g:ctrlp_clear_cache_on_exit = 0
+
+    " Don't switch the window if the selected buffer is already open. I want
+    " to open another view on this buffer in most cases.
+    let g:ctrlp_switch_buffer = 0
+
+" FSWitch settings.
+    " Defaults don't work well for my projects.
+    augroup vimrc
+        autocmd BufEnter *.cc let b:fswitchdst  = 'h'
+                          \ | let b:fswitchlocs = './'
+        autocmd BufEnter *.h  let b:fswitchdst  = 'cc,c'
+                          \ | let b:fswitchlocs = './'
+    augroup END
+
+    " Switch to corresponding header/source file.
+    nnoremap <silent> <Leader>h :FSHere<CR>
+
+" netrw settings.
+    " Don't create ~/.vim/.netrwhist history file.
+    let g:netrw_dirhistmax = 0
+endif
+
+
+" AUTO COMMANDS
+
+" Use a custom auto group to prevent problems when the vimrc files is sourced
+" multiple times.
+if has('autocmd')
+    augroup vimrc
+
+" Go to last position of opened files. Taken from :help last-position-jump.
+        autocmd BufReadPost *
+            \ if line("'\"") > 1 && line("'\"") <= line('$') |
+            \     execute "normal! g'\"" |
+            \ endif
+" But not for Git commits, go to beginning of the file.
+        autocmd BufReadPost COMMIT_EDITMSG normal! gg
+
+" Make sure 'list' and 'number' is disabled in help files. This is necessary
+" when switching to a help buffer which is in the background with :buffer as
+" these options are local to windows (and not only to buffers). This happens
+" because I often want to use only one window and thus the help buffer is in
+" the background.
+        autocmd BufWinEnter *.txt
+            \ if &filetype == 'help' |
+            \     setlocal nolist |
+            \     setlocal nonumber |
+            \ endif
+
+" Automatically disable 'paste' mode when leaving insert mode. Thanks to
+" Raimondi in #vim on Freenode (2010-08-14 23:01 CEST). Very useful as I only
+" want to paste once and then 'paste' gets automatically unset. InsertLeave
+" doesn't exist in older Vims. Use "*p to paste X11's selection, no need for
+" 'paste' in this case.
+        if exists('##InsertLeave')
+            autocmd InsertLeave * set nopaste
+        endif
+
+" Write all files when running :mak[e] before 'makeprg' is called.
+" QuickFixCmdPre doesn't exist in older Vims.
+        if exists('##QuickFixCmdPre')
+            autocmd QuickFixCmdPre * wall
+        endif
+
+" Don't ignore case while in insert mode, but ignore case in all other modes.
+" This causes <C-N>/<C-P> to honor the case and thus only complete matching
+" capitalization. But while searching (/) 'ignorecase' is used.
+" InsertEnter/InsertLeave doesn't exist in older Vims.
+        if exists('##InsertEnter') && exists('##InsertLeave')
+            autocmd InsertEnter * set noignorecase
+            autocmd InsertLeave * set   ignorecase
+        endif
+
+" Display a warning when editing a file which contains "do not edit" (ignoring
+" the case) and similar messages in the first lines of the file, for example
+" template files which were preprocessed or auto-generated files. Especially
+" useful when the header is not displayed on the first screen, e.g. when the
+" old position is restored.
+        function! s:SearchForDoNotEditHeader()
+            " Only search the first 20 lines to prevent false positives, e.g.
+            " in scripts which write files containing this warning and ignore
+            " the case (\c). (Can't use search()'s {stopline} as we might not
+            " start searching from the top.)
+            let l:search = '\c\(do not \(edit\|modify\)\|autogenerated by\)'
+            let l:match = search(l:search, 'n')
+            if l:match == 0 || l:match > 20
+                return
+            endif
+
+            echoerr 'Do not edit this file! (Maybe a template file.)'
+        endfunction
+        autocmd BufRead * call s:SearchForDoNotEditHeader()
+
+" AFTER/FTPLUGIN AUTO COMMANDS
+
+" Disable spell checking for files which don't need it.
+        autocmd FileType deb  setlocal nospell
+        autocmd FileType diff setlocal nospell
+        autocmd FileType tar  setlocal nospell
+" Fix to allow Vim edit crontab files as crontab doesn't work with
+" backupcopy=auto.
+        autocmd FileType crontab setlocal backupcopy=yes
+" Don't use the modeline in git commits as the diff created by `git commit -v`
+" may contain one which could change the filetype or other settings of the
+" commit buffer. Also make sure we use only 72 characters per line which is
+" the recommendation for git commit messages (http://tpope.net/node/106).
+        autocmd FileType gitcommit let g:secure_modelines_allowed_items = [] |
+                                 \ setlocal textwidth=72
+" Fix 'include' setting for shell files to recognize '.' and 'source'
+" commands.
+        autocmd FileType sh let &l:include = '^\s*\(\.\|source\)\s\+'
+" Use the same comment string as for Vim files in Vimperator files.
+        autocmd FileType vimperator setlocal commentstring=\"%s
+" Use TeX compiler for (La)TeX files.
+        autocmd FileType tex compiler tex
+
+" FTDETECT AUTO COMMANDS
+
+" Recognize .md as markdown files (Vim default is .mkd).
+        autocmd BufRead,BufNewFile *.md set filetype=mkd
+" Recognize .test as Tcl files.
+        autocmd BufRead,BufNewFile *.test set filetype=tcl
+
+" OTHER AUTO COMMANDS
+
+" Disable spell checking, displaying of list characters and long lines when
+" viewing documentation.
+        autocmd BufReadPost /usr/share/doc/* setlocal nospell nolist | 2match
+
+" Use diff filetype for mercurial patches in patch queue.
+        autocmd BufReadPost */.hg/patches/* set filetype=diff
+
+    augroup END
+endif
+
+
+" CUSTOM FUNCTIONS AND COMMANDS
+
+if has('eval')
+" Convenient command to see the difference between the current buffer and the
+" file it was loaded from, thus the changes you made. Thanks to the
+" vimrc_example.vim file in Vim's source. Modified to use the same filetype
+" for the diffed file as the filetype for the original file.
+    if !exists(':DiffOrig')
+        command DiffOrig
+            \ let s:diff_orig_filetype = &filetype
+            \ | vertical new
+            \ | let &filetype = s:diff_orig_filetype
+            \ | unlet s:diff_orig_filetype
+            \ | set buftype=nofile
+            \ | read ++edit #
+            \ | 0d_
+            \ | diffthis
+            \ | wincmd p
+            \ | diffthis
+    endif
+endif