gref

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2025 License: MIT Imports: 13 Imported by: 0

README

GREF

MIT License Go

A fast, interactive search and replace tool for your terminal, powered by Bubble Tea and Lipgloss.


GREF Demo

Features

  • 🚀 Fast regex search across files and directories
  • 🖥️ Interactive TUI for previewing and selecting replacements
  • 🧠 Smart selection: choose lines to replace, bulk select/deselect
  • 🛡️ Atomic file writes for safe replacements
  • 🎨 Customizable styles and clear error messages
  • 🏃 Efficient for large codebases

Install

go install github.com/albertize/gref@latest

Usage

gref [options] <pattern> [replacement] [directory]
Options
  • -h, --help : Show help message and exit
  • -i, --ignore-case : Ignore case in pattern matching
Arguments
  • <pattern>: Regex pattern to search for
  • [replacement]: Replacement string (if omitted, only search)
  • [directory]: Directory to search (default: current directory)
Example
gref foo bar src      # Replace 'foo' with 'bar' in src directory
gref foo              # Search for 'foo' only
gref -i Foo           # Case-insensitive search for 'Foo'
gref --help           # Show help message

Keyboard Controls

  • //j/k: Move cursor up/down
  • //h/l: Scroll horizontally
  • Home/End: Scroll to start/end of line
  • Space: Select/deselect a result for replacement
  • a: Select all results
  • n: Deselect all results
  • Enter: Confirm selected replacements
  • Esc: Cancel confirmation
  • q/Ctrl+c: Exit

Project Structure

  • main.go: CLI entry, argument parsing, help, and UI launch
  • model.go: TUI state, rendering, and event handling
  • search.go: Efficient regex search across files
  • replace.go: Safe, grouped replacements in files
  • test/test.go: Example/test code for HTTP and logging

Performance

GREF is designed for speed and efficiency:

  • Optimized Search: Buffered reading and byte-level processing for large files
  • Parallel File Traversal: Uses Go concurrency for fast directory scanning
  • Atomic Replacements: Writes changes to temp files before replacing originals
  • Minimal UI Overhead: Responsive TUI adapts to terminal size
  • Selective Processing: Only selected lines/files are modified


Contributing

Contributions are welcome! Please submit issues or pull requests for bug fixes, features, or improvements.


License

MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL