A powerful command-line tool for searching files with multiple keywords, offering flexible context display and advanced filtering options.
- 🔍 Search for multiple keywords across files
- 📂 Recursive directory searching
- 🎯 File type filtering
- 📝 Context-aware results (show surrounding lines or characters)
- 🎨 Syntax-highlighted output
- 📊 Search statistics
- 🚫 Binary file filtering
- 📏 File size limits
- 🎛️ Case-sensitive search options
- 📁 Custom ignore patterns
Choose your preferred installation method:
npm install -g gak
brew tap 8bit-wraith/gak
brew install gak
# Add our PPA
curl -s https://gak.8b.is/key.gpg | sudo apt-key add -
echo "deb https://gak.8b.is/apt stable main" | sudo tee /etc/apt/sources.list.d/gak.list
# Install GAK
sudo apt update
sudo apt install gak
git clone https://github.com/8bit-wraith/gak.git
cd gak
npm install -g .
- GAK works seamlessly on Windows with automatic path handling
- Windows-specific directories (Program Files, System32, etc.) are automatically ignored
- Windows batch (.bat) and PowerShell (.ps1) files are recognized with special icons
- Use PowerShell or Command Prompt to run GAK commands
- Forward slashes (/) in paths work in addition to backslashes ()
gak [options] [keywords...]
# Find files containing "password"
gak password
# Find files with both "config" and "secure" in /etc
gak -p /etc config secure
# Search only in JavaScript and Python files
gak -t js,py class method
# Show 2 lines of context around matches
gak -l 2 TODO
# Only show filenames of matches
gak -q password
Option | Description | Default |
---|---|---|
-p, --path <path> |
Search path | Current directory |
-b, --binary |
Include binary files | false |
-i, --ignore <patterns...> |
Glob patterns to ignore | /node_modules/, /.git/ |
-t, --type <extensions...> |
File extensions to search (e.g., js,py,txt) | All files |
-c, --context <chars> |
Characters to show around match | 0 |
-cb, --context-before <chars> |
Characters to show before match | 0 |
-ca, --context-after <chars> |
Characters to show after match | 0 |
-l, --lines <count> |
Lines to show around match | 0 |
-lb, --lines-before <count> |
Lines to show before match | 0 |
-la, --lines-after <count> |
Lines to show after match | 0 |
-m, --max-matches <count> |
Maximum matches per file | No limit |
-C, --case-sensitive |
Enable case-sensitive search | false |
-s, --size <limit> |
Skip files larger than size (e.g., 1mb, 500kb) | 10mb |
-q, --quiet |
Only show file names | false |
--stats |
Show search statistics | false |
-ss, --show-skips |
Show skipped files | false |
GAK provides flexible ways to show context around matches:
# Show 5 characters before and after matches
gak -c 5 searchterm
# Show 2 lines before and 3 lines after matches
gak -lb 2 -la 3 searchterm
# Show 2 lines of context in both directions
gak -l 2 searchterm
# Search only specific file types
gak -t js,py,md searchterm
# Ignore additional patterns
gak -i "**/dist/**" "**/build/**" searchterm
# Include binary files in search
gak -b searchterm
# Limit file size (skip larger files)
gak -s 500kb searchterm
# Show search statistics
gak --stats searchterm
# Show skipped files
gak -ss searchterm
# Quiet mode (only show file names)
gak -q searchterm
# Case-sensitive search
gak -C searchterm
GAK uses emojis to indicate file types in the output:
- 📜 JavaScript (.js, .mjs)
- 🐍 Python (.py)
- 🦀 Rust (.rs)
- 🐹 Go (.go)
- 💎 Ruby (.rb)
- 🐘 PHP (.php)
- ☕ Java (.java)
- ⚡ C/C++ (.c, .cpp)
- 📋 Header files (.h)
- 🎨 CSS (.css)
- 🌐 HTML (.html)
- 📝 Markdown (.md)
- 📦 JSON (.json)
- ⚙️ YAML (.yml, .yaml)
- 🐚 Shell scripts (.sh, .bash)
- 📄 Text files (.txt)
- 📂 Other files
- Skips binary files by default
- Configurable file size limits
- Efficient glob-based file filtering
- Optimized for large codebases
GAK offers several advantages over traditional grep:
- Faster search performance due to modern Node.js streams and optimized file handling
- Smart file filtering that skips binary files and large files by default
- Efficient memory usage even with large codebases
- Beautiful, colorful output with file type emojis
- Clear, human-readable error messages
- Progress indicators and search statistics
- No need to remember complex regex patterns for basic searches
- Multi-keyword search without complex regex (just space-separate your terms!)
- Character-level context control (show exactly N chars before/after match)
- Smart file type detection and filtering
- Modern glob pattern support for ignoring files/directories
- Sensible defaults that work for most use cases
- Case-insensitive search by default (use -C for case-sensitive)
- Automatic binary file skipping
- Smart file size limits to prevent hanging on large files
- Flexible context display (characters or lines)
- Statistics about your search
- Quiet mode for scripting
- Show skipped files for debugging
GAK provides clear error messages for common issues:
- Permission denied errors
- Invalid file paths
- Binary file detection
- Size limit violations
- Invalid regex patterns
Imagined by @8bit-wraith(Hue) & @aye.is
MIT