3 Create Your Script
zrep edited this page 2024-04-06 09:38:08 +02:00

How to create your own script

The scripts used in zpi are using the autoload function of Zsh. This means that your script have to be in $fpath to be found by Zsh. This is where zpi comes in.

zpi is created to handle the installation and management of scripts.

Create your script

Zsh has a certain way it works and this influences how your scripts should be created.

The script should only contain one main function that has the same name as the file.

Example:

  • my_script
  • function my_script()

Based on my research, it is possible to have functions within the main function, so it should be possible to create complex and very interesting scripts for the community.

zpi depends on one file to display help information to the user. Using zpi author/package help will display the information in the file USAGE.

The file README.md is used on the web page when people visit your package page. This file is optional, but highly recommended.

In other words, the file structure you should aim for is:

  • script_name
  • USAGE
  • README.md

Once you've registered for an account, you can then add your scripts and files. They will then be packaged, uploaded to the repository and made available to the community.

On your zrep account page, you will have access to statistics and other goodies.