Shell completions and man pages¶
ag generates its own completion scripts and man pages from the same command definitions as --help, so they
cannot describe a flag that does not exist.
Completions¶
ag completions bash # also: zsh, fish, powershell, elvish
Install the script where your shell looks for completions. These are the usual places; adjust them to your setup.
| Shell | One-off (current session) | Permanent |
|---|---|---|
| bash | source <(ag completions bash) |
ag completions bash > ~/.local/share/bash-completion/completions/ag |
| zsh | source <(ag completions zsh) (after compinit) |
ag completions zsh > "${fpath[1]}/_ag" |
| fish | ag completions fish \| source |
ag completions fish > ~/.config/fish/completions/ag.fish |
| PowerShell | ag completions powershell \| Out-String \| Invoke-Expression |
add that line to $PROFILE |
| elvish | eval (ag completions elvish \| slurp) |
add that line to ~/.config/elvish/rc.elv |
Pre-generated copies for the version in this checkout are kept in
docs/reference/completions/ (ag.bash, _ag,
ag.fish, _ag.ps1, ag.elv), so you can install them without running ag. They are generated by
scripts/gen_cli_docs.py; CI fails when they are stale, and cargo test -p agentgit-cli --test completions compares them
with the binary.
What is verified, and where:
- The scripts for bash, zsh and fish are syntax-checked by the shell itself (
bash -n,zsh -n,fish --no-execute) and the PowerShell script is parsed by PowerShell's own parser, in CI (theshellsjob installs zsh and fish and setsAG_REQUIRE_COMPONENTS=shell, so a missing shell fails instead of being skipped). The elvish script is generated and compared with the stored copy, but no elvish is installed anywhere to parse it. - bash completion is exercised for real: the test sources the script and asks it to complete a command prefix, a
subcommand prefix, the values of
--colorand the shell names afterag completions. - Completing in a live zsh, fish, PowerShell or elvish session is not tested: only that the scripts parse (not even that, for elvish).
Man pages¶
ag man # the top-level page on standard output
ag man --dir /tmp/ag-man # ag.1 and one page per command (ag-stream-create.1, …)
man -l /tmp/ag-man/ag-integrate.1
To install them system-wide, write them to a directory on MANPATH (for example ~/.local/share/man/man1).
Copies are kept in docs/reference/man/, checked like
the completions. The build stamp that ag --version prints is left out of the stored copies because it changes with
every commit; ag man itself includes it.
The release archives do not ship completions or man pages yet: generate them with the two commands above. (Releasing lists what an archive contains.)