Skip to content

fish-template

Usage
fish-template [list|info|new|edit|regen|show|ls|help] [ARGS...]

Builds your own fish functions from templates, without writing code. Pick a target (what runs: one command, the first installed of several, a sequence of steps, a set of subcommands, a command line with slots for your arguments, a command line per host or per operating system, or a jump to a directory), stack any modifiers on it (how it runs: extra arguments, environment changes, a confirmation question, a working directory, retries, a time limit, a log file, a desktop notification), and answer a few questions. fish-template writes a documented function with its own --help to the user-dots functions/ directory, where it autoloads in every shell. Functions can call each other, so a sequence can chain functions you made earlier.

Each generated function keeps its answers (its recipe) as settings at the top of its body. edit asks the questions again with those answers as defaults; regen rebuilds after fish-template improves; show prints the recipe so you can copy it to another machine.

list List the templates and presets
info NAME Show a template’s settings and defaults, or a preset
new [NAME] Create a function (asks for anything not given)
edit NAME Change a function made by fish-template
regen NAME...|--all Rebuild functions from their recipes
show NAME Print a function’s recipe, ready for --from
ls List the functions you made
help, -h, --help Show this help

Options for new and edit:

-t, --target T Target: command, fallback, sequence, dispatcher,
snippet, per-host, per-os or jump
-w, --with M[,M] Modifiers to stack (repeatable)
-s, --set KEY=VAL Give a setting. List settings take space-separated
words; line settings take one entry per --set
-f, --from FILE Read settings from a recipe file (never executed)
-p, --preset P Start from a preset (see list)
-o, --output DIR Write to DIR instead of the user-dots functions/
-n, --dry-run Print the function instead of writing it
-y, --yes Ask nothing; unset settings take their defaults
--force Replace an existing file
0 Success, or help was shown
1 Refused (file exists or was not made by fish-template), cancelled, or failed
2 Usage error: unknown subcommand, template or setting, or a bad value

Templates live in templates/ (targets/, modifiers/, presets/). Output goes to $__fish_user_dots_path/functions/, which conf.d puts first on $fish_function_path, so your function overrides one of the same name from this config. fish-template warns when a name shadows a builtin, a function or a command, and never replaces a file it did not make.

Full guide, with every template’s settings: help config templates

Terminal window
fish-template new
fish-template new claude --preset allow-telemetry --yes
fish-template new rg --target command --set command_cmd=rg --with args --set args_prepend=--smart-case --yes
fish-template edit deploy

Dependencies: fzf

Classification: manual-section(12-function-templates)

See also: 12. FUNCTION TEMPLATES