Commands¶
ghgrab supports interactive usage and three command groups: release, agent, and config.
Repository URLs for the main TUI flow and agent commands can target GitHub, GitLab, Codeberg, Gitea, Forgejo, and compatible self-hosted instances unless noted otherwise below.
Base command¶
ghgrab [URL] [--cwd] [--no-folder] [--token TOKEN]
Global options¶
Flag |
Description |
|---|---|
|
Download files to the current working directory |
|
Download directly into the target directory without a repository subfolder |
|
Use a one-time GitHub token without storing it. |
Typing a keyword at the TUI home screen opens repository search mode. That search flow currently uses GitHub only.
Release downloads¶
The release command, with alias rel, downloads release assets from a repository:
ghgrab rel <owner/repo> [OPTIONS]
This command is currently GitHub-only.
Common examples¶
# Download the best matching artifact
ghgrab rel sharkdp/bat
# Download a specific release tag
ghgrab rel sharkdp/bat --tag v0.25.0
# Allow prereleases when selecting the latest release
ghgrab rel starship/starship --prerelease
# Force an exact asset with regex
ghgrab rel sharkdp/bat --asset-regex "x86_64.*windows.*zip"
# Extract archives after download
ghgrab rel sharkdp/bat --extract
# Install an extracted binary into a target directory
ghgrab rel sharkdp/bat --extract --bin-path ~/.local/bin
Release options¶
Flag |
Description |
|---|---|
|
Download a specific release tag |
|
Allow prereleases when |
|
Match a specific release asset |
|
Override detected operating system |
|
Override detected architecture |
|
Prefer |
|
Extract archive assets after download |
|
Use a custom output directory |
|
Install the selected file or binary into the provided directory (use |
|
Download into the current working directory |
|
Use a one-time GitHub token for this run. |
Selection behavior¶
If one asset clearly matches the current platform,
ghgrabdownloads it immediately.If several close matches exist,
ghgrabshows an interactive picker.If no assets match the filters, the command exits with an error.
Agent mode¶
The agent command is designed for non-interactive tooling. It prints a stable JSON envelope with:
api_versionokcommanddataon successerroron failure
Fetch a repository tree¶
ghgrab agent tree https://github.com/rust-lang/rust
# GitLab also works
ghgrab agent tree https://gitlab.com/gitlab-org/gitlab
Download specific paths¶
ghgrab agent download https://github.com/rust-lang/rust src/tools README.md --out ./tmp
# Codeberg / Forgejo / Gitea URLs also work
ghgrab agent download https://codeberg.org/forgejo/forgejo cmd --out ./tmp
Download a subtree¶
ghgrab agent download https://github.com/rust-lang/rust --subtree src/tools --out ./tmp
Download the entire repository¶
ghgrab agent download https://github.com/rust-lang/rust --repo --out ./tmp
Agent command rules¶
agent download --repocannot be combined with positional paths.agent download --repocannot be combined with--subtree.agent download --subtreecannot be combined with positional paths.
Agent options¶
agent tree¶
Flag |
Description |
|---|---|
|
Use a one-time GitHub token. |
agent download¶
Flag |
Description |
|---|---|
|
Download the entire repository |
|
Download one subtree path |
|
Download into the current working directory |
|
Skip the repository subfolder |
|
Use a custom output directory |
|
Use a one-time GitHub token. |
Configuration¶
The config command manages saved settings:
ghgrab config set token YOUR_TOKEN
ghgrab config set path "/your/custom/path"
ghgrab config list
ghgrab config unset token
ghgrab config unset path
config list masks stored tokens before printing them.
Runtime token auto-detection (no save)¶
If you do not want to store a token, use:
ghgrab rel sharkdp/bat --token auto
ghgrab agent tree https://github.com/rust-lang/rust --token gh
Behavior:
Uses
gh auth tokenat runtime only.Never prints the raw token.
If multiple token lines are returned,
ghgrabreports that multiple tokens were found and uses one token.