From 76483193b4947c5d78768073982c633946770044 Mon Sep 17 00:00:00 2001 From: Milos Djurica Date: Mon, 3 Nov 2025 12:43:03 +0100 Subject: [PATCH] feature: add foundry's forge plugin --- plugins/forge/README.md | 36 ++++++++++++++++++++++++++++++++++ plugins/forge/forge.plugin.zsh | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 plugins/forge/README.md create mode 100644 plugins/forge/forge.plugin.zsh diff --git a/plugins/forge/README.md b/plugins/forge/README.md new file mode 100644 index 000000000..8f9de6c48 --- /dev/null +++ b/plugins/forge/README.md @@ -0,0 +1,36 @@ +## Forge plugin + +The Forge plugin provides completion and useful aliases for +[Foundry Forge](https://getfoundry.sh/forge/overview), a command-line tool that tests, builds, and deploys +smart contracts. + +To use it, add `forge` to the plugins array of your zshrc file: + +```zsh +plugins=(... forge) +``` + +## Aliases + +| Alias | Command | Description | +| :-------- | :--------------- | :----------------------- | +| `finit` | `forge init` | Initialize a new project | +| `fb` | `forge build` | Build the project | +| `fcmp` | `forge compile` | Compile contracts | +| `ft` | `forge test` | Run tests | +| `fdoc` | `forge doc` | Generate documentation | +| `ffmt` | `forge fmt` | Format code | +| `fl` | `forge lint` | Lint code | +| `fsnap` | `forge snapshot` | Create a snapshot | +| `fcov` | `forge coverage` | Generate coverage report | +| `ftree` | `forge tree` | Show dependency tree | +| `fcl` | `forge clean` | Clean build artifacts | +| `fgeiger` | `forge geiger` | Run geiger (security) | +| `fcfg` | `forge config` | Show configuration | +| `fupd` | `forge update` | Update dependencies | +| `fbind` | `forge bind` | Generate bindings | + +## Requirements + +This plugin requires [Foundry](https://book.getfoundry.sh/getting-started/installation) to be installed and +the `forge` command to be available in your PATH. diff --git a/plugins/forge/forge.plugin.zsh b/plugins/forge/forge.plugin.zsh new file mode 100644 index 000000000..3bfdd6913 --- /dev/null +++ b/plugins/forge/forge.plugin.zsh @@ -0,0 +1,34 @@ +# Foundry Forge plugin for oh-my-zsh + +# Aliases for common Foundry Forge commands +alias finit='forge init' +alias fb='forge build' +alias fcmp='forge compile' +alias ft='forge test' +alias fdoc='forge doc' +alias ffmt='forge fmt' +alias fl='forge lint' +alias fsnap='forge snapshot' +alias fcov='forge coverage' +alias ftree='forge tree' +alias fcl='forge clean' +alias fgeiger='forge geiger' +alias fcfg='forge config' +alias fupd='forge update' +alias fbind='forge bind' + +# COMPLETION FUNCTION +if (( ! $+commands[forge] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `forge`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_forge" ]]; then + typeset -g -A _comps + autoload -Uz _forge + _comps[forge]=_forge +fi + +# Generate completion file in the background +forge completions zsh >| "$ZSH_CACHE_DIR/completions/_forge" &| \ No newline at end of file