zsh
Declarative zsh configuration. Describe your entire shell setup — environment variables, login profile, options, aliases, prompt, history, completions — as a single Lua table and rootbeer generates all the zsh files for you: ~/.zshenv (bootstrap), <dir>/.zshenv, <dir>/.zprofile, and <dir>/.zshrc.
lua
local zsh = require("rootbeer.zsh")Example
lua
zsh.config({
keybind_mode = "emacs",
options = { "CORRECT", "EXTENDED_GLOB" },
env = {
EDITOR = "nvim",
VISUAL = "$EDITOR",
},
aliases = {
g = "git",
ls = "lsd -l --group-directories-first",
},
history = { size = 10000 },
evals = { "mise activate zsh" },
})For per-machine overrides, see Multi-Device Config. For the conditionals pattern, see Core Concepts.
API Reference
config(cfg)
Applies the full zsh configuration. Generates ~/.zshenv (bootstrap), <dir>/.zshenv, <dir>/.zprofile, and <dir>/.zshrc from a single config table.
aliasestable<string, string>optionalShell aliases defined via
alias name="command".completions(zsh.CompletionConfig)optionalCompletion system settings.
dirstringoptionalZDOTDIR path. Defaults to
"~/.config/zsh". All zsh files are written here and a bootstrap ~/.zshenv is created to set ZDOTDIR.envtable<string, string>optionalEnvironment variables written to
.zshenv (available in all shells).evalsstring[]optionalCommands wrapped in
eval "$(cmd)".extra(string|string[])optionalRaw lines appended as-is to the zshrc.
functionstable<string, string>optionalShell functions. Keys are names, values are the function body. Supports multi-line
[[...]] strings.history(zsh.HistoryConfig)optionalHistory settings.
hookstable<string, string|string[]>optionalZsh hook registrations via
add-zsh-hook. Keys are hook names (e.g. "precmd"), values are function names or lists of function names.keybind_mode("emacs"|"vi")optionalInput mode (
set -o emacs or set -o vi).keybindingstable<string, string>optionalbindkey mappings (e.g. { ["^R"] = "my-widget" }).optionsstring[]optionalsetopt options (e.g. "CORRECT", "EXTENDED_GLOB").profile(zsh.ProfileConfig)optionalLogin shell configuration written to
.zprofile.promptstringoptionalRaw
PS1 prompt string.sourcesstring[]optionalFile paths to source.
variablestable<string, string>optionalShell variable assignments (not exported).
vcs_info(boolean|zsh.VcsInfoConfig)optionalEnable git branch info in the prompt via
vcs_info. When true, uses default format " (%b)". Automatically sets PROMPT_SUBST, adds a precmd hook, and autoloads vcs_info.widgetsstring[]optionalFunction names to register as ZLE widgets via
zle -N. The function must be defined in functions.zsh.CompletionConfig
cachestringoptionalCache directory for completion data.
enablebooleanoptionalRun
compinit. Defaults to true.menu_selectbooleanoptionalArrow-key menu selection. Defaults to
true.stylestable<string, string>optionalRaw
zstyle entries (pattern → value).vi_navbooleanoptionalUse hjkl for menu navigation. Defaults to
false.zsh.HistoryConfig
appendbooleanoptionalAppend to history file. Defaults to
true.dedupbooleanoptionalRemove duplicate entries. Defaults to
true.filestringoptionalHISTFILE path. Defaults to $ZDOTDIR/.zsh_history.ignorestringoptionalHISTIGNORE pattern.save_sizenumberoptionalSAVEHIST. Defaults to size.sharebooleanoptionalShare history across sessions. Defaults to
true.sizenumberoptionalHISTSIZE. Defaults to 10000.zsh.ProfileConfig
evalsstring[]optionalCommands wrapped in
eval "$(cmd)".extra(string|string[])optionalRaw lines appended as-is.
path_appendstring[]optionalDirectories appended to
$PATH.path_prependstring[]optionalDirectories prepended to
$PATH.sourcesstring[]optionalFile paths to source.
zsh.VcsInfoConfig
check_for_changesbooleanoptionalEnable dirty/staged indicators. Defaults to
true.formatsstringoptionalFormat string for
vcs_info. Defaults to " (%b)".