Package/Tool zsh-plugin
A command-line tool to generate new Zsh plugins.
This tool scaffolds Zsh plugins with best practices built-in, including function tracking for clean unloading, optional alias support, autoloaded functions, and CI/CD workflows for shellcheck and shellspec. Choose from minimal, simple, or complete templates to match your plugin's complexity.
Install
)
Command init
<NAME>
Results
Initialize a new Zsh plugin structure in the directory zsh-NAME-plugin.
he resulting plugin contains the following content.
-
A file
NAME.plugin.zshwhich consists of the main plugin lifecycle functions.- A function
NAME_plugin_initis included with comments to show how to save environment variables, add aliases, and add to eitherpathorfpath. - A function
NAME_plugin_unloadis included with comments to demonstrate custom clean-up actions. - An example global variable
NAME_EXAMPLEset during source time. - A call during source time to set any dependencies the plugin wishes to declare.
- A function
-
If the option
add-bash-wrapperis defined, a fileNAME.bashis included which provides an entry point for Bash users to load the plugin. -
A directory
.github/workflowsand a Github Actions script namedshell.ymlto automate shellcheck and shellspec. Generation will be skipped if theno-github-diroption is checked or both the optionsno-shell-checkandno-shell-specare set as the workflow then has nothing to do. -
A directory
functionswith an example autoloaded function namedNAME_example. Generation will be skipped if theno-functions-diroption is set. -
If the option
add-bin-diris set an emptybindirectory for plugin specific binaries is created. -
A file
.gitignore. Generation will be skipped if both the optionsno-shell-checkandno-shell-specare set. -
A directory
doc. Generation will be skipped if theno-shell-docoption is set. -
A file
Makefilefor GNU Make. Generation will be skipped if the optionsno-shell-check,no-shell-doc, andno-shell-specare all true. -
A file
README.mdcontaining only a basic skeleton. Generation will be skipped if theno-readmeis set.
Templates
Rather than setting all options manually, three templates are provided with pre-defined selection of settings. These are described in the table below.
| Feature / Template | minimal | simple | complete |
|---|---|---|---|
add-bin-dir |
false | false | true |
add-bash-wrapper |
false | false | true |
no-aliases |
true | false | false |
no-functions-dir |
true | true | false |
no-git-init |
false | false | false |
no-github-dir |
true | true | false |
no-readme |
true | false | false |
no-shell-check |
true | false | false |
no-shell-doc |
true | false | false |
no-shell-spec |
true | false | false |
Example
Given the following execution:
A complete plugin, with all possible content, is created as follows:
─ zsh-containers-plugin
├─ .github/ # unless no-github-dir OR
│ └─ workflows/ # no-shell-check AND no-shell-check AND no-shell-spec
│ └─ shell.yml
├─ bin/ # when add-bin-dir
│ └─ .gitkeep
├─ functions/ # unless no-functions-dir
│ └─ containers_example
├─ .git # unless no-git-init
├─ .gitignore # unless no-git-init
├─ Makefile # unless no-shell-check AND no-shell-check AND no-shell-spec
├─ mkdoc.zsh # unless no-shell-doc
├─ README.md
├─ containers.bash # when add-bash-wrapper
└─ containers.plugin.zsh
License(s)
The contents of this repository are made available under the following licenses:
Apache-2.0
Copyright 2025 Simon Johnston <johnstonskj@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
See the enclosed file LICENSE-Apache.
MIT
Copyright 2025 Simon Johnston <johnstonskj@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See the enclosed file LICENSE-MIT.
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
For information on contributing to this project, see the following.
- Project Code of Conduct.
- Project Contribution Guidelines.
- Project TODO Items in Issues.
- Repository Change Log.