Skip to content

Templates

Pascal Zarrad edited this page Apr 27, 2025 · 9 revisions

Templates are an easy way to customize zsh to fit your needs. You can use them to apply entire predefined snippets of a .zshrc. This enables a fast and easy way to to customize psh without many experience in shell scripting - but even advanced users can combine templates and plugins to use compose great things together!

If you want to add something that needs to interact with the user or system where psh is being installed, a plugins may be the better choice.

How templates work

Templates are simple files with a special directive in the head of the file that tells psh where to put the template into the .zshrc. This enables the fast and easy creation of short snippets (like a collection of aliases). The templates must be located in the templates directory and should end with <file-name>.template.zshrc. The templates are being loaded and applied at the position in the .zshrc, that you defined using the #PSH_TEMPLATE=<TYPE> directive.

Example

Your templates have to have the #PSH_TEMPLATE=<TYPE>-directive to work. Where type defines the position of the template in your generated .zshrc. A list of all available types is available under "Template positions".

#PSH_TEMPLATE=END
alias psh=zsh
# A comment and then another alias
alias test=ps aux | grep java

Template positions

The following types are available for the position of templates in the templates directive:

Type Position
START Placed directly after the generated header, but before zplug is being loaded
BETWEEN_ANTIDOTE_SOURCE_AND_PLUGINS Placed after Antidote has been sourced, but before plugins are loaded
END Placed at the end of the the .zshrc
Clone this wiki locally