zgen
Manage Zsh plugins
SYNOPSIS
zgen <command> [<arguments>...]
PARAMETERS
load <user/repo> [<type> [<plugin_name>]]
Loads a plugin or theme from a GitHub repository (e.g., zsh-users/zsh-autosuggestions). <type> can specify how to load (e.g., main, plugin, theme, oh-my-zsh). <plugin_name> is for specific oh-my-zsh plugins.
load-plugin <path>
Loads a plugin from a specified local file path.
theme <user/repo> [<name>]
Loads a theme from a GitHub repository, optionally specifying a theme file name within the repo.
oh-my-zsh
Initializes core Oh My Zsh functionalities, allowing its plugins and themes to be loaded.
oh-my-zsh-plugins <plugin>...
Loads one or more specific Oh My Zsh plugins by name (e.g., git, history).
save
Generates or updates the init.zsh file in the zgen directory, which contains the pre-compiled code for all configured plugins and themes. This command must be run after any changes to your plugin list in .zshrc.
update [<user/repo>...]
Updates specified plugins or all configured plugins if no arguments are given. This fetches the latest versions from their respective Git repositories.
reset
Clears all compiled zgen files and repositories, then rebuilds everything from scratch. Useful for resolving inconsistencies or errors.
clean
Removes any plugin repositories that are no longer referenced in your zgen configuration within .zshrc.
check
Checks for available updates for your configured plugins without performing the update operation.
help [<command>]
Displays general help for zgen or specific usage information for a given subcommand.
DESCRIPTION
zgen is a lightweight and highly performant Zsh plugin manager designed to significantly reduce shell startup times. It achieves this by pre-compiling plugins and themes into optimized .zsh files, which are then sourced directly on shell initialization, bypassing the overhead of dynamic sourcing from multiple Git repositories.
It supports loading plugins and themes from GitHub, local paths, and provides seamless integration with Oh My Zsh. zgen offers commands for managing your Zsh environment, including updating plugins, regenerating the compiled setup, and cleaning up unused repositories. Its focus on speed and simplicity makes it a popular choice for users seeking a highly responsive Zsh shell.
CAVEATS
zgen relies on Zsh and Git being installed and accessible. While highly optimized, very dynamic Zsh plugins that rely on real-time sourcing of specific files (rather than simple function definitions) might not behave as expected with zgen's pre-compilation. Always ensure to run zgen save after modifying your plugin list in .zshrc to apply changes.
TYPICAL CONFIGURATION
To integrate zgen into your Zsh environment, you'll typically add a block of code to your ~/.zshrc file. This involves sourcing the zgen script, defining your desired plugins and themes using zgen commands, and then calling zgen save inside a conditional block:
# ~/.zshrc excerpt
source "${HOME}/.zgen/zgen.zsh"
if ! zgen saved; then
# Oh My Zsh core
zgen oh-my-zsh
# Plugins
zgen load zsh-users/zsh-syntax-highlighting
zgen load zsh-users/zsh-autosuggestions
zgen oh-my-zsh-plugins git history
# Theme
zgen theme romkatv/powerlevel10k
zgen save
fi
PERFORMANCE OPTIMIZATION
zgen's primary advantage is its unique approach to plugin management. Instead of sourcing individual plugin files on every shell startup, it consolidates and compiles all defined plugins and themes into a single, optimized init.zsh file. This file is then sourced once, dramatically reducing the I/O operations and processing overhead during Zsh initialization, leading to a much faster interactive shell experience.
HISTORY
zgen was created by Tarjo (tarjoilija) as a lightweight and significantly faster alternative to existing Zsh plugin managers. Its development focused on addressing the common issue of slow shell startup times, introducing concepts like asynchronous loading and pre-compilation into a single file to optimize Zsh initialization. It quickly gained popularity among users seeking a highly performant Zsh setup.