Skip to content

Plugins

Pascal Zarrad edited this page Feb 23, 2020 · 6 revisions

Plugins are the opposite of templates - they provide rich functionality by allowing the extension of psh. They enable the possibility to built complex logic (or even call external scripts like a python helper script) to generate something that is system specific (like find something and put the path of it into the .zshrc).

For example, plugins are used by psh to apply all the antigen plugins. Also as powerline-fonts is not usable on the Windows Subsystem for Linux without installing it manually, they are used to determine if the fallback theme should be used to bypass that problem.

Creating a plugin

To create a plugin, you have to add a create a yourplugin.sh in the plugins folder of psh. You should add a bash shebang at the top of the plugin's script. Also it is recommended to add a header that contains all information about the plugin. From there, you're free to use anything that bash can do. The API can help you to interact with the .zhsrc.

#!/bin/bash

#==================================================================
# Script Name   : psh-node-installer
# Description	: Enables oh-my-zsh's node and npm plugin
# Args          : -
# Author       	: Pascal Zarrad
# Email         : P.Zarrad@outlook.de
#==================================================================

apply_antigen_bundle "node"
apply_antigen_bundle "npm"
apply_antigen_bundle "bower"
apply_antigen_bundle "grunt"
apply_antigen_bundle "bundler"

For example, the plugin that adds extensions that are useful for working with NodeJS.

API

psh comes with some API functions to simplify the creation of plugins. All custom functions/commands can be found in the below table.

Command Function
write_zshrc Write some content to the .zshrc
apply_antigen_bundle Add an antigen bundle to load to the .zshrc
apply_antigen_theme Add a theme loaded by antigen to the .zshrc
Clone this wiki locally