Skip to content

stanleyndachi/lazy.zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

πŸ’€ lazy.zsh

lazy.zsh is a lightweight and minimal Zsh plugin manager.

✨ Features

  • πŸš€ Fast & Lightweight – No unnecessary dependencies, just pure Zsh and Git.
  • ⚑ One-Line Bootstrap – Quickly install lazy.zsh by adding a small snippet to .zshrc.
  • πŸ›  Reproducible Environments – Easily reproduce the same Zsh setup by using the same .zshrc.
  • 🌍 Supports Multiple Sources – Install plugins using:
    • Short GitHub URLs (username/repository)
    • Full Git URLs (https://, git@, etc.)
    • Local paths
  • πŸ“Œ Version Locking – Supports locking plugins to a specific branch, tag, or commit.
  • πŸ”„ Automatic Updates – Set an update interval and get reminders to keep plugins up to date.
  • πŸ”— Easy Plugin Management – Install, update, list, and remove plugins with simple commands.

⚑️ Requirements

  • zsh
  • git

πŸ“¦ Installation

  • Add the following code to your .zshrc.

    # ----- lazy.zsh configuration: start -----
    # define your plugins here
    declare -a LAZYZ_PLUGINS=(
        # example plugins:
        "https://github.com/stanleyndachi/lazy.zsh"      # Full URL
        "zsh-users/zsh-syntax-highlighting"              # GitHub short URL
        "zsh-users/zsh-autosuggestions"
        # "Aloxaf/fzf-tab"
        # "/home/user/mysecret/plugin local=true"        # Local plugin
    )
    
    export LAZYZ_DATA_HOME="$HOME/.local/share/zsh/lazyz"  # plugin storage directory
    export LAZYZ_CACHE_HOME="$HOME/.cache/zsh/lazyz"       # plugin cache directory
    export LAZYZ_UPDATE_REMINDER=true                      # enable update reminders
    export LAZYZ_UPDATE_INTERVAL=14                        # update interval (days)
    
    # bootstrap lazy.zsh
    function .lazyz_bootstrap() {
        if [[ -f "${LAZYZ_DATA_HOME}/lazy.zsh/lazy.zsh" ]]; then
            source "${LAZYZ_DATA_HOME}/lazy.zsh/lazy.zsh"
        elif command -v git &>/dev/null; then
            print "[lazyz]: lazy.zsh not found. Downloading ..."
            rm -rf "${LAZYZ_DATA_HOME}/lazy.zsh" &>/dev/null
            git clone --depth=1 'https://github.com/stanleyndachi/lazy.zsh' "${LAZYZ_DATA_HOME}/lazy.zsh"
            source "${LAZYZ_DATA_HOME}/lazy.zsh/lazy.zsh"
        else
            print "[lazyz]: lazy.zsh couldn't be installed. Please install 'git'"
      fi
    }
    .lazyz_bootstrap
    unset -f .lazyz_bootstrap
    alias zshrc="${EDITOR:-vi} ~/.zshrc"    # Quick access to the ~/.zshrc file
    # ----- lazy.zsh configuration: end -----

    πŸ”Ή Tip: Ensure that compinit is loaded after lazy.zsh.

  • Source the .zshrc or restart your terminal.

    source ~/.zshrc
  • Run lazyz help to see all available commands.

βš™οΈ Configuration

Defining Plugins

lazy.zsh uses a flat, declarative string-based configuration. Each plugin is defined as a single string inside the LAZYZ_PLUGINS array. The first token specifies the plugin source, while any following key=value pairs act as options that control how the plugin is handled.

declare -a LAZYZ_PLUGINS=(
    "plugin_url option1=value1 option2=value2 ..."
)

Internally, lazy.zsh parses these strings into structured plugin metadata using associative arrays, but users only interact with the simple, flat format. This design avoids complex data structures while remaining expressive and easy to parse in pure Zsh.

Available Plugin Options
Option Description Required
(implicit) Plugin source (first token in entry) βœ… Yes
branch Git branch to checkout ❌ No
commit Lock plugin to a specific commit ❌ No
tag Lock plugin to a specific tag ❌ No
build Commands executed in the plugin directory after install or update ❌ No
local Is a local plugin (default=false) ❌ No
Example Configuration
declare -a LAZYZ_PLUGINS=(
    # Full URL (latest commit from the default branch)
    "https://github.com/stanleyndachi/lazy.zsh"
    # Lock the plugin to a specific commit
    "Aloxaf/fzf-tab commit=abcd123"
    "zsh-users/zsh-syntax-highlighting branch=develop commit=123abcd"
    # Use a Git tag instead of the latest commit
    "zsh-users/zsh-autosuggestions tag=v0.7.1"
    # Plugin that requires a build step
    "zdharma-continuum/fast-syntax-highlighting build='make && make install' branch=dev"
    # Local plugin
    "/home/user/mysecret/plugin local=true"
)
// JSON equivalent
{
    "https://github.com/stanleyndachi/lazy.zsh": {},
    "Aloxaf/fzf-tab": {
        "commit": "abcd123"
    },
    "zsh-users/zsh-syntax-highlighting": {
        "branch": "develop",
        "commit": "123abcd"
    },
    "zsh-users/zsh-autosuggestions": {
        "tag": "v0.7.1"
    },
    "zdharma-continuum/fast-syntax-highlighting": {
        "build": "make && make install",
        "branch": "dev",
    },
    "/home/user/mysecret/plugin": {
        "local": "true"
    },
}

Other Options

  • To get a reminder to update your plugins, set LAZYZ_UPDATE_REMINDER=true.
  • LAZYZ_UPDATE_INTERVAL defines how often (in days) to get a reminder (default: 14 days).
  • LAZYZ_DATA_HOME defines the directory where plugins will be installed (default: ~/.local/share/zsh/lazyz/).
  • LAZYZ_CACHE_HOME defines the cache directory (default: ~/.cache/zsh/lazyz/).

πŸ”Ž Missing Features

This design keeps lazy.zsh minimal and predictable, avoids implicit sourcing, and gives users full control over load order and startup performance. To load plugins, manually source them in your .zshrc. For example:

# Load powerlevel10k theme
source "$LAZYZ_DATA_HOME/powerlevel10k/powerlevel10k.zsh-theme"

πŸ”Ή Tip: Some plugins may have different filenames (e.g., plugin.zsh, init.zsh). Check the plugin’s documentation for the correct source file.

❓ FAQs

What is a ghost plugin

Ghost plugin = a directory under LAZYZ_DATA_HOME that:

  1. Looks like a plugin (git repo or plugin files)
  2. Is not represented by any entry in LAZYZ_PLUGINS

Why does a plugin entry in LAZYZ_PLUGINS array have a weird syntax?

Simple! Zsh shell does not have built-in support for multi-dimmensional array

Where can I get a starter .zshrc file?

A well-structured starter .zshrc is available in the this repository.

curl -o ~/.zshrc 'https://raw.githubusercontent.com/stanleyndachi/lazy.zsh/refs/heads/main/examples/zshrc'

How do I uninstall lazy.zsh?

  1. Delete the code snippet added during installation from your .zshrc.

  2. Remove the plugins directory (optional)

    • To remove only lazy.zsh:

      rm -rf "${LAZYZ_DATA_HOME}/lazy.zsh"
    • To remove ALL installed plugins:

      echo "Are you sure you want to delete all plugins? (y/N)"
      read -r confirm
      [[ "$confirm" =~ ^[Yy]$ ]] && rm -rf "${LAZYZ_DATA_HOME}"

πŸ“ TODO

🌐 Other Resources

  • autoupdate-oh-my-zsh-plugins - oh-my-zsh plugin for auto updating of git-repositories in $ZSH_CUSTOM folder

  • awesome-zsh-plugins - A collection of ZSH frameworks, plugins, tutorials & themes inspired by the various awesome list collections out there.

About

πŸ’€ Zsh plugin manager

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages