Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

ghgrab - "grab anything you want"

A simple, pretty terminal tool that lets you search and download files from GitHub without leaving your CLI.

Rust crates.io npm version PyPI version license

ghgrab demo

ghgrab provides a streamlined command-line interface for cherry-picking specific files or folders from any GitHub repository, powered by the Rust tokio and ratatui ecosystem. Focused on speed and ease of use, it offers a beautiful TUI that lets you grab exactly what you need; all without the wait times of a full git clone.

Why use ghgrab?

  • No more clone-and-delete: Grab exactly what you need, when you need it.
  • Easy on the eyes: A clean terminal interface that makes browsing feel smooth.
  • Works where you are: Installs quickly via NPM, Cargo, or PIP.
  • Find things fast: Quickly search and navigate through any repo's folders with fuzzy search.
  • Repo discovery built in: Type a repo keyword from home to search GitHub repos, filter them, then open instantly.
  • File Preview: Preview source code and text files directly in the TUI.
  • Handles the big stuff: Built-in support for GitHub LFS (Large File Storage).
  • Batch mode: Select a bunch of files and folders to download them all at once.
  • Release downloads: Grab GitHub release artifacts with OS/architecture-aware selection.

Installation

NPM

npm install -g @ghgrab/ghgrab

Cargo

cargo install ghgrab

pipx (Recommended for Python)

pipx install ghgrab

Nix

To have the latest commit:

nix run github:abhixdd/ghgrab

To have a specific tagged version:

nix run "github:abhixdd/ghgrab/<tag>"

Aur (Arch linux)

yay -S ghgrab-bin

Quick Start

Just type ghgrab to start browsing:

ghgrab

Or, if you already have a link, just paste it in:

# Browse a repository ghgrab https://github.com/rust-lang/rust # Download to current directory directly ghgrab https://github.com/rust-lang/rust --cwd --no-folder

You can also type a repository keyword on the home screen (for example ratatui) and press Enter to open repository search mode.

CLI Flags

FlagDescription
--cwdForces download to the current working directory.
--no-folderDownloads files directly without creating a subfolder for the repo.
--token <TOKEN/AUTO/GH>Use a specific GitHub token for this run (doesn't save to settings). auto/gh uses gh auth token at runtime.

Release Downloads

You can also download GitHub release assets directly with the user-facing release command or its short alias rel.

Basic examples:

# Download the best matching artifact for your OS and architecture ghgrab rel sharkdp/bat # Extract an archive after download ghgrab rel sharkdp/bat --extract # Download a specific release tag ghgrab rel sharkdp/bat --tag v0.25.0 # Match a specific asset by regex ghgrab rel sharkdp/bat --asset-regex "x86_64.*windows.*zip" # Download into a custom directory ghgrab rel sharkdp/bat --extract --out ./tmp/bat # Install the selected file or extracted binary into a target directory ghgrab rel sharkdp/bat --extract --bin-path ~/.local/bin

Basic release flags:

FlagDescription
--tag <TAG>Download a specific release tag.
--asset-regex <REGEX>Match a specific release asset by regex.
--extractExtract archive assets after download.
--out <DIR>Download into a custom output directory.
--bin-path <DIR>Copy the selected file or extracted binary into the provided directory.
--os <OS>Override detected operating system.
--arch <ARCH>Override detected architecture.
Show release download usage, flags, and examples

How selection works:

  • If there is one clear best asset match for your OS and architecture, ghgrab downloads it directly.
  • If multiple close matches exist, ghgrab shows an interactive picker in the terminal.
  • Type the asset number and press Enter to continue.
  • Type q and press Enter to cancel the picker.
# Pick a release tag explicitly ghgrab rel sharkdp/bat --tag v0.25.0 # Match assets with a regex ghgrab rel sharkdp/bat --asset-regex "x86_64.*linux.*tar.gz" # Extract an archive after download ghgrab rel sharkdp/bat --extract # Install the selected file or extracted binary into a target directory ghgrab rel sharkdp/bat --extract --bin-path ~/.local/bin # Download to a custom directory ghgrab rel sharkdp/bat --extract --out ./tmp/bat # Force Windows x64 asset selection ghgrab rel BurntSushi/ripgrep --os windows --arch amd64 # Allow prereleases when selecting the latest release ghgrab rel starship/starship --prerelease

Release Flags

FlagDescription
--tag <TAG>Download a specific release tag instead of the latest matching release.
--prereleaseAllow prereleases when --tag is not provided.
--asset-regex <REGEX>Match a specific release asset by regex. Useful for forcing one artifact and skipping the picker.
--os <OS>Override detected operating system for asset selection.
--arch <ARCH>Override detected architecture for asset selection.
--file-type <TYPE>Prefer any, archive, or binary assets.
--extractExtract archive assets after download. Supports .zip, .tar.gz, .tgz, and .tar.xz.
--out <DIR>Download into a custom output directory.
--bin-path <DIR>Copy the selected file or extracted binary into the provided directory.
--cwdDownload into the current working directory.
--token <TOKEN/AUTO/GH>Use a one-time GitHub token for this run without saving it. auto/gh uses gh auth token at runtime.

Release Examples

# Download a specific ripgrep release for Windows x64 ghgrab rel BurntSushi/ripgrep --tag 15.1.0 --os windows --arch amd64 # Use a regex to choose one exact asset ghgrab rel sharkdp/bat --asset-regex "x86_64.*windows.*zip" # Install an extracted binary into your local bin directory ghgrab rel sharkdp/bat --extract --bin-path ~/.local/bin # Use the long command form ghgrab release sharkdp/bat

Environment Variables

ghgrab also accepts GitHub tokens from environment variables:

  • GHGRAB_GITHUB_TOKEN
  • GITHUB_TOKEN

Runtime token auto mode

If you already use GitHub CLI, you can avoid manual token copy/paste:

ghgrab rel sharkdp/bat --token auto ghgrab agent tree https://github.com/rust-lang/rust --token gh
  • Uses gh auth token at runtime only.
  • Never prints the raw token.
  • If multiple token lines are returned, ghgrab reports this and uses one token.

Agent Mode

For scripts, agents, and other non-interactive workflows, ghgrab includes a machine-friendly agent command that prints a stable JSON envelope with api_version, ok, command, and either data or error.

# Fetch the repository tree as JSON ghgrab agent tree https://github.com/rust-lang/rust # Fetch the repository tree with an explicit token for scripts or agents ghgrab agent tree https://github.com/rust-lang/rust --token YOUR_TOKEN # Download specific paths from a repository ghgrab agent download https://github.com/rust-lang/rust src/tools README.md --out ./tmp # Download an explicit 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 # Download into the current working directory without creating a repo folder ghgrab agent download https://github.com/rust-lang/rust src/tools --cwd --no-folder

You can pass --token <TOKEN> to agent tree and agent download when an external tool, CI job, or coding agent should authenticate without relying on saved local config.

Configuration

To manage your settings:

# Set your token ghgrab config set token YOUR_TOKEN # Set a custom download folder ghgrab config set path "/your/custom/path" # View your current settings (token is masked) ghgrab config list # Remove settings ghgrab config unset token ghgrab config unset path

Theming

ghgrab supports custom color themes via a TOML config file.

  • Linux/macOS: ~/.config/ghgrab/theme.toml
  • Windows: %APPDATA%\ghgrab\theme.toml

Any missing key falls back to the default Tokyo Night theme. Colors must use #RRGGBB hex format.

See examples/theme.toml for a complete example.

Keyboard Shortcuts (How to move around)

We've kept it pretty standard, but here's a quick cheat sheet:

KeyAction
Enter (home)Open URL or start repository search
Enter / l / Right (browser)Enter directory
Backspace / h / LeftGo back to previous folder
Delete (home)Delete character at cursor
TabAuto-fill https://github.com/ (Home page)
/Start Searching (File list)
EscExit Search or Return Home (file list) or Quit (home screen)
q / QQuit (from file list)
Ctrl+qForce Quit (anywhere)
SpaceToggle selection for the current item
p / PPreview current file
aSelect All items
uUnselect all items
d / DDownload selected items
iToggle Icons (Emoji / ASCII)
g / HomeJump to Top
G / EndJump to Bottom

Repository Search Mode Shortcuts

KeyAction
j / k / / Move selection
EnterOpen selected repository
fToggle include/exclude forks
mCycle minimum stars (Any, 10+, 50+, 100+, 500+, 1000+)
lCycle language filter
sCycle sort (Stars, Updated, Name)
xReset all filters
rRefresh current search
EscReturn to home input

Join the community

If you find a bug, have an idea for a cool new feature, or just want to help out, we'd love to hear from you! Check out our Contributing Guide to see how you can get involved.

License

Distributed under the MIT License. It's open, free, and yours to play with. See LICENSE for the fine print.

关于 About

A simple, pretty terminal tool that lets you search and download files from GitHub without leaving your CLI.
clifiledownloadergithubnodepythonratatuirusttui

语言 Languages

Rust93.6%
Python2.9%
JavaScript2.7%
Nix0.5%
Shell0.3%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
105
Total Commits
峰值: 61次/周
Less
More

核心贡献者 Contributors