├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── .markdownlint.json
├── .vscode
└── zpm.code-workspace
├── LICENSE
├── Makefile
├── README.md
├── bin
└── @zpm-plugin-helper
├── functions
├── @zpm-add-autoload
├── @zpm-addfpath
├── @zpm-addpath
├── @zpm-async-source
├── @zpm-background-initialization
├── @zpm-clean
├── @zpm-compile
├── @zpm-get-plugin-autoload
├── @zpm-get-plugin-basename
├── @zpm-get-plugin-bin-path
├── @zpm-get-plugin-destination-path
├── @zpm-get-plugin-documentation-hyperlink
├── @zpm-get-plugin-documentation-link
├── @zpm-get-plugin-file-path
├── @zpm-get-plugin-functions-path
├── @zpm-get-plugin-name
├── @zpm-get-plugin-origin
├── @zpm-get-plugin-origin-type
├── @zpm-get-plugin-path
├── @zpm-get-plugin-type
├── @zpm-initialize-plugin
├── @zpm-launch-plugin-helper
├── @zpm-load-plugins
├── @zpm-log
├── @zpm-no-source
├── @zpm-source
├── @zpm-upgrade
├── _zpm
└── zpm
├── images
├── demo.gif
├── logo.png
└── logo.svg
├── lib
├── imperative.zsh
└── init.zsh
├── plugins
└── .gitkeep
├── tests
└── startup
│ ├── bash
│ └── zsh
├── zpm.zsh
└── zshrc
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 |
12 | **To Reproduce**
13 |
14 | **Expected behavior**
15 |
16 | **Additional context**
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 |
12 | **Describe the solution you'd like**
13 |
14 | **Describe alternatives you've considered**
15 |
16 | **Additional context**
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tests/_output/*
2 | !tests/_output/.gitkeep
3 |
4 | plugins/*
5 | !plugins/.gitkeep
6 |
7 | .directory
8 | *.zwc
9 | *.old
10 | *.bak
11 | *~
12 |
--------------------------------------------------------------------------------
/.markdownlint.json:
--------------------------------------------------------------------------------
1 | {
2 | "MD033": false,
3 | "MD004": false,
4 | "MD013": false,
5 | "MD041": false
6 | }
7 |
--------------------------------------------------------------------------------
/.vscode/zpm.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": ".."
5 | }
6 | ],
7 | "settings": {}
8 | }
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
167 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | clean:
2 | @rm -f functions/*.zwc
3 | @rm -f lib/*.zwc
4 |
5 | all: clean
6 | @for file in functions/* ; do \
7 | beautysh --indent-size 2 --force-function-style fnpar $$file ; \
8 | done
9 |
10 | @for file in lib/* ; do \
11 | beautysh --indent-size 2 --force-function-style fnpar $$file ; \
12 | done
13 |
14 | @beautysh --indent-size 2 --force-function-style fnpar zpm.zsh
15 | @beautysh --indent-size 2 --force-function-style fnpar bin/@zpm-plugin-helper
16 |
17 | test:
18 | zsh tests/base.test.zsh
19 |
20 | .PHONY: all clean test
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 | Zpm is a plugin manager for ZSH who combines the imperative and declarative approach. At first run, zpm will do complex logic and generate cache, after that will be used cache only, so it makes this framework to be very fast.
17 |
18 |
19 |
20 |
21 |
22 | ## Features
23 |
24 | - **Speed**. Fastest plugin manager (Really, after the first run, zpm will not be used at all)
25 | - **Compatibility**. Zpm plugins are compatible with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
26 | - **Portability**. Zpm runs on Linux, Android, OpenWrt, FreeBSD and macOS
27 | - Support for async loading
28 | - Dependencies between packages
29 | - Hooks
30 | - Function autoloading
31 | - Extensible
32 | - Possibility to use github/gitlab/bitbucket mirrors (useful for China)
33 |
34 | ## Table of Contents
35 |
36 | - [Features](#features)
37 | - [Table of Contents](#table-of-contents)
38 | - [Stats](#stats)
39 | - [Base dependences](#base-dependences)
40 | - [Installation](#installation)
41 | - [How to use](#how-to-use)
42 | - [Load plugin](#load-plugin)
43 | - [Plugin name](#plugin-name)
44 | - [Plugin tags](#plugin-tags)
45 | - [`if` and `if-not` conditions](#if-and-if-not-conditions)
46 | - [Upgrade](#upgrade)
47 | - [Clean](#clean)
48 | - [Configuration](#configuration)
49 | - [Troubleshooting](#troubleshooting)
50 | - [Developing process](#developing-process)
51 | - [TODO](#todo)
52 | - [Changelog](#changelog)
53 |
54 | ## Stats
55 |
56 |
57 | Test on Intel I7-8750H, SanDisk SD7SN6S, 16GB RAM
58 |
59 |
60 | ```sh
61 | zsh -i -c exit 0.00s user 0.00s system 102% cpu 0.006 total
62 | zsh -i -c exit 0.01s user 0.00s system 101% cpu 0.006 total
63 | zsh -i -c exit 0.00s user 0.01s system 99% cpu 0.006 total
64 | zsh -i -c exit 0.01s user 0.00s system 102% cpu 0.007 total
65 | zsh -i -c exit 0.00s user 0.00s system 100% cpu 0.007 total
66 | zsh -i -c exit 0.01s user 0.00s system 100% cpu 0.007 total
67 | zsh -i -c exit 0.00s user 0.00s system 101% cpu 0.007 total
68 | zsh -i -c exit 0.00s user 0.00s system 100% cpu 0.006 total
69 | zsh -i -c exit 0.00s user 0.00s system 101% cpu 0.007 total
70 | zsh -i -c exit 0.00s user 0.00s system 100% cpu 0.008 total
71 | ```
72 |
73 |
74 |
75 |
76 |
77 | Test on Raspberry Pi Zero W, Raspbian 10, 1GHz Broadcom BCM2835 ARMv6, 512MB RAM
78 |
79 |
80 | ```sh
81 | zsh -i -c exit 0.14s user 0.05s system 85% cpu 0.219 total
82 | zsh -i -c exit 0.14s user 0.05s system 43% cpu 0.436 total
83 | zsh -i -c exit 0.14s user 0.05s system 58% cpu 0.325 total
84 | zsh -i -c exit 0.12s user 0.07s system 90% cpu 0.206 total
85 | zsh -i -c exit 0.15s user 0.05s system 84% cpu 0.231 total
86 | zsh -i -c exit 0.15s user 0.04s system 46% cpu 0.407 total
87 | zsh -i -c exit 0.13s user 0.06s system 62% cpu 0.306 total
88 | zsh -i -c exit 0.11s user 0.08s system 83% cpu 0.227 total
89 | zsh -i -c exit 0.14s user 0.05s system 47% cpu 0.403 total
90 | zsh -i -c exit 0.11s user 0.08s system 62% cpu 0.307 total
91 | ```
92 |
93 |
99 |
100 | ```sh
101 | zsh -i -c exit 0.09s user 0.03s system 83% cpu 0.144 total
102 | zsh -i -c exit 0.10s user 0.02s system 29% cpu 0.412 total
103 | zsh -i -c exit 0.10s user 0.02s system 69% cpu 0.173 total
104 | zsh -i -c exit 0.10s user 0.03s system 73% cpu 0.165 total
105 | zsh -i -c exit 0.10s user 0.02s system 81% cpu 0.150 total
106 | zsh -i -c exit 0.10s user 0.02s system 71% cpu 0.170 total
107 | zsh -i -c exit 0.10s user 0.02s system 85% cpu 0.141 total
108 | zsh -i -c exit 0.10s user 0.02s system 42% cpu 0.283 total
109 | zsh -i -c exit 0.11s user 0.02s system 68% cpu 0.176 total
110 | zsh -i -c exit 0.10s user 0.02s system 75% cpu 0.161 total
111 | ```
112 |
113 |
114 |
115 |
116 |
117 | With this set of plugins. 51 total
118 |
174 |
175 |
176 | ## Base dependences
177 |
178 | - [zsh](https://www.zsh.org/)
179 | - [git](https://git-scm.com/)
180 | - One of these:
181 | - [GNU Parallel](https://www.gnu.org/software/parallel/) for fastest parallel execution.
182 | - [Rush](https://github.com/shenwei356/rush) for fastest parallel execution.
183 | - [xargs](https://www.gnu.org/software/findutils/) as fallback
184 | - [curl](https://curl.se/) for GitHub Gists
185 | - [Termux](http://termux.com/) for Android
186 | - [cli-html](https://www.npmjs.com/package/cli-html) view html in terminal. _Optional_
187 | - [cli-markdown](https://www.npmjs.com/package/cli-markdown) view markdown in terminal. _Optional_
188 |
189 | ## Installation
190 |
191 | Add the following text into `.zshrc`
192 |
193 | ```sh
194 | if [[ ! -f ~/.zpm/zpm.zsh ]]; then
195 | git clone --recursive https://github.com/zpm-zsh/zpm "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/@zpm"
196 | fi
197 | source "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/@zpm/zpm.zsh"
198 | # Or source our zshrc
199 | # source "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/@zpm/zshrc"
200 | ```
201 |
202 | If you don't have `.zshrc` copy example of `.zshrc` from zpm
203 |
204 | ```sh
205 | ln -sf ~/.zpm/zshrc ~/.zshrc
206 | ```
207 |
208 | ## How to use
209 |
210 | Currently zpm has following commands
211 |
212 | - load - will download and load plugin [See](#load-plugin)
213 | - if/if-not - conditions for following command [See](#if-and-if-not-conditions)
214 | - upgrade - will upgrade plugin, without parameters will upgrade all plugins [See](#upgrade)
215 | - clean - will clean zpm cache [See](#clean)
216 |
217 | The set of commands can be expanded extended using plugins
218 |
219 |
220 | Plugins for zpm itself
221 |
222 |
223 | - [zpm-readme](https://github.com/zpm-zsh/zpm-readme) - Show plugin readme in terminal
224 | - [zpm-info](https://github.com/zpm-zsh/zpm-info) - Show plugin info in terminal
225 | - [zpm-telemetry](https://github.com/zpm-zsh/zpm-telemetry) - Send telemetry data. Keep calm. Data is sent using GitHub and you can see it before sending.
226 |
227 |
228 |
229 |
230 | ### Load plugin
231 |
232 | **Important**
233 |
234 | > Be carefully, zpm doesn't guarantee loading order in call. So if you need to load a plugin **before** antoher, you should do 2 separate `zpm load` calls.
235 | > This is very important for oh-my-zsh plugins, because @omz-core should be loaded before
236 |
237 | Plugin name must have next form: `@plugin-type/user/plugin-name`. This plugin can be enabled using
238 |
239 | ```sh
240 | # Add to `~/.zshrc` after zpm initialization:
241 | zpm load @plugin-type/user/plugin-name
242 | ```
243 |
244 | > Notice: if you change `~/.zshrc`, you need to remove zpm cache using: `zpm clean`
245 |
246 | Additionaly they can have some tags. Tags must be separated by commas `,` without spaces, tag parameters must be separated from tag names or another tag parameters by `:`
247 |
248 | ```sh
249 | # plugin type
250 | # | plugin name
251 | # | | tag
252 | # | | | tag parameters,
253 | # | | | divided by `:` boolean tag
254 | # | | | | |
255 | # ↓ ↓ ↓ ↓ ↓
256 | @type/some/plugin,apply:source:path:fpath,async
257 | ```
258 |
259 | ### Plugin name
260 |
261 | If plugin name starts with `@word`, this word will be used as plugin type. Plugin name will be used to detect plugin origin url.
262 |
263 | - `@github/` or `@gh/` - plugin will be cloned from GitHub, this is default value, so you don't need to set it
264 | - `@gitlab/` or `@gl/` - plugin will be cloned from GitLab
265 | - `@bitbucket/` or `@bb/` - plugin will be cloned from Bitbucket
266 | - `@git/` - plugin will be cloned via git. Be careful, zpm can't detect origin for this plugin type, you must specify origin using tag `origin:`
267 | - `@gist/` - plugin will be downloaded from GitHub Gist
268 | - `@omz/` - zpm will use a plugin from oh-my-zsh, oh-my-zsh will be download if not installed. **Important**: you shoud load `@omz` before any other plugin from on-my-zsh: `zpm load @omz`.
269 |
270 | - `@omz/theme/` - will load a theme from omz dir: `/themes/*.zsh-theme`
271 | - `@omz/lib/` - will load a lib from omz dir: `/lib/*.zsh`
272 | -
273 |
274 | Example:
275 |
276 |