opsbrew
A powerful CLI tool designed to simplify and shorten repetitive DevOps terminal commands. opsbrew provides shortcuts for common Git and kubectl operations, with features like fuzzy finders, command recipes, and project templates.
Source: github.com/nghiadaulau/opsbrew
Features
- Git Operations: Enhanced Git commands with fuzzy finder for branches
- Kubernetes Management: kubectl shortcuts with context/namespace switching, HPA management, and scaling
- File Operations: Common file operations like backup, diff, find, and grep
- Command Recipes: Save and run command macros for daily workflows
- Project Templates: Bootstrap common project structures
- Safe Defaults: Built-in
--dry-runand--confirmflags - Configuration: YAML-based configuration (global + per-repo)
- Shell Completions: Full shell completion support
Installation
Quick Install (Recommended)
# Install latest version
go install github.com/nghiadaulau/opsbrew@latest
# Add Go bin to PATH (if not already added)
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc
source ~/.bashrc
# Verify installation
opsbrew --version
Pre-built Binaries
# Linux/macOS
wget https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Linux_x86_64.tar.gz
tar -xzf opsbrew_Linux_x86_64.tar.gz
sudo mv opsbrew /usr/local/bin/
# Windows
curl -L -o opsbrew_Windows_x86_64.zip https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Windows_x86_64.zip
# Extract and add to PATH
From Source
git clone https://github.com/nghiadaulau/opsbrew.git
cd opsbrew
go build -o opsbrew .
sudo mv opsbrew /usr/local/bin/
📖 Detailed Installation Guide: See INSTALL.md for complete instructions including upgrade, uninstall, and troubleshooting.
Releases
This project uses GoReleaser for automated releases. When you push a tag starting with v*, it automatically:
- Builds binaries for Linux, macOS, and Windows
- Creates GitHub releases with all artifacts
- Generates checksums for verification
Creating a Release
git tag v1.0.0
git push origin v1.0.0
See RELEASE.md for detailed release instructions.
Documentation
This project uses mdBook to generate beautiful documentation sites.
- Live Documentation: https://nghiadaulau.github.io/opsbrew
- Documentation Setup: See DOCUMENTATION.md for details
The documentation site includes:
- Complete command reference
- Installation guides
- Release information
- Interactive search
- Dark/light theme toggle
Using Go Install
go install github.com/nghiadaulau/opsbrew@latest
Quick Start
-
Initialize configuration:
opsbrew --help # This will create ~/.opsbrew.yaml with default settings -
Git operations:
opsbrew git status # Enhanced git status opsbrew git sync # git pull --rebase opsbrew git checkout # Fuzzy finder for branches -
Kubernetes operations:
opsbrew k8s kctx # Switch kubectl context opsbrew k8s kns # Switch namespace opsbrew k8s klogs # Get pod logs with fuzzy finder opsbrew k8s khpa set-min my-hpa 2 # Set HPA min replicas opsbrew k8s kscale deployment my-app 5 # Scale deployment -
Command recipes:
opsbrew brew save daily-sync # Save a new recipe opsbrew brew run daily-sync # Execute saved recipe opsbrew brew list # List all recipes -
File operations:
opsbrew file backup config.yaml # Create backup opsbrew file find "*.yaml" # Find files by pattern opsbrew file diff file1.yaml file2.yaml # Compare files -
Project templates:
opsbrew init github-actions my-app # Create GitHub Actions workflow opsbrew init k8s-deployment my-app # Create K8s Deployment opsbrew init k8s-service my-app # Create K8s Service
Configuration
opsbrew uses YAML configuration files. The global config is located at ~/.opsbrew.yaml, and you can have per-repository configs in .opsbrew.yaml.
Example Configuration
# Git configuration
git:
default_branch: "main"
auto_fetch: true
aliases:
st: "status"
co: "checkout"
sync: "pull --rebase"
# Kubernetes configuration
kubernetes:
default_context: "production"
context_aliases:
prod: "production-cluster"
dev: "development-cluster"
# Command recipes
brew:
recipes:
daily-sync:
description: "Daily development workflow"
commands:
- "git fetch --all"
- "git pull origin main"
- "git checkout -b feature/$(date +%Y%m%d)"
tags: ["daily", "git"]
# UI settings
ui:
colors: true
verbose: false
confirm: false
dry_run: false
Commands
Git Commands
opsbrew git status- Enhanced git status with colorsopsbrew git sync- Pull with rebaseopsbrew git checkout [branch]- Checkout branch with fuzzy finderopsbrew git branch- List branches with fuzzy finderopsbrew git fetch- Fetch all remotesopsbrew git pull- Pull from current branchopsbrew git push- Push to current branch
Kubernetes Commands
opsbrew k8s kctx [context]- Switch kubectl context with fuzzy finderopsbrew k8s kns [namespace]- Switch namespace with fuzzy finderopsbrew k8s klogs [pod]- Get pod logs with fuzzy finderopsbrew k8s kpods- List pods with fuzzy finderopsbrew k8s ksvc- List servicesopsbrew k8s kingress- List ingress resourcesopsbrew k8s kexec [pod] [command]- Execute command in podopsbrew k8s khpa list- List all HPAsopsbrew k8s khpa get [name]- Get HPA detailsopsbrew k8s khpa set-min [name] [value]- Set minimum replicasopsbrew k8s khpa set-max [name] [value]- Set maximum replicasopsbrew k8s khpa set-target [name] [value]- Set target CPU percentageopsbrew k8s kscale [type] [name] [replicas]- Scale deployment/replicaset/statefulset
File Commands
opsbrew file open [file]- Open file with default editoropsbrew file find [pattern] [dir]- Find files by name or patternopsbrew file grep [pattern] [file]- Search for text in filesopsbrew file backup [file] [backup-path]- Create backup of fileopsbrew file diff [file1] [file2]- Show differences between files
Brew Commands (Command Recipes)
opsbrew brew save [name]- Save a new recipeopsbrew brew list- List all saved recipesopsbrew brew run [name]- Execute a saved recipeopsbrew brew delete [name]- Delete a recipeopsbrew brew edit [name]- Edit a recipe
Init Commands (Project Templates)
opsbrew init github-actions [name]- Create GitHub Actions workflowopsbrew init k8s-deployment [name]- Create Kubernetes Deployment manifestopsbrew init k8s-service [name]- Create Kubernetes Service manifestopsbrew init k8s-pod [name]- Create Kubernetes Pod manifestopsbrew init k8s-configmap [name]- Create Kubernetes ConfigMap manifestopsbrew init dockerfile [name]- Create multi-stage Dockerfileopsbrew init list- List available templates
Global Flags
--config- Specify config file path--verbose, -v- Enable verbose output--dry-run- Show what would be done without executing--confirm- Skip confirmation prompts
Shell Completions
Generate shell completions:
# Bash
opsbrew completion bash > ~/.bash_completion.d/opsbrew
# Zsh
opsbrew completion zsh > "${fpath[1]}/_opsbrew"
# Fish
opsbrew completion fish > ~/.config/fish/completions/opsbrew.fish
# PowerShell
opsbrew completion powershell > opsbrew.ps1
Examples
Daily Development Workflow
# Start the day
opsbrew brew run daily-sync
# Check git status
opsbrew git status
# Switch to a feature branch
opsbrew git checkout
# Switch to development context
opsbrew k8s kctx dev
# Check pod logs
opsbrew k8s klogs
# Manage HPA settings
opsbrew k8s khpa set-min my-app 2
opsbrew k8s khpa set-max my-app 10
# Scale deployment
opsbrew k8s kscale deployment my-app 5
# File operations
opsbrew file backup config.yaml
opsbrew file find "*.yaml"
Deployment Workflow
# Pre-deployment checks
opsbrew brew run deploy-check
# Switch to production context
opsbrew k8s kctx prod
# Check application status
opsbrew k8s kpods
opsbrew k8s ksvc
Project Setup
# Create GitHub Actions workflow
opsbrew init github-actions my-api
# Create Kubernetes manifests
opsbrew init k8s-deployment my-api
opsbrew init k8s-service my-api
opsbrew init k8s-configmap my-api
# Create Dockerfile
opsbrew init dockerfile my-api
Development
Prerequisites
- Go 1.24 or later
- Git
- kubectl (for Kubernetes commands)
Building from Source
git clone https://github.com/nghiadaulau/opsbrew.git
cd opsbrew
go mod download
go build -o opsbrew .
Running Tests
go test ./...
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- spf13/cobra - CLI framework
- ktr0731/go-fuzzyfinder - Fuzzy finder
- fatih/color - Color output
- spf13/viper - Configuration management
Installation Guide
Quick Install
Using Go Install (Recommended)
# Install latest version
go install github.com/nghiadaulau/opsbrew@latest
# Add Go bin to PATH (if not already added)
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc
source ~/.bashrc
# Or for zsh
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc
source ~/.zshrc
# Verify installation
opsbrew --version
Using Pre-built Binaries
Linux (x86_64)
# Download latest release
wget https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Linux_x86_64.tar.gz
# Extract and install
tar -xzf opsbrew_Linux_x86_64.tar.gz
sudo mv opsbrew /usr/local/bin/
# Verify installation
opsbrew --version
macOS (x86_64)
# Download latest release
curl -L -o opsbrew_Darwin_x86_64.tar.gz https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Darwin_x86_64.tar.gz
# Extract and install
tar -xzf opsbrew_Darwin_x86_64.tar.gz
sudo mv opsbrew /usr/local/bin/
# Verify installation
opsbrew --version
macOS (Apple Silicon)
# Download latest release
curl -L -o opsbrew_Darwin_arm64.tar.gz https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Darwin_arm64.tar.gz
# Extract and install
tar -xzf opsbrew_Darwin_arm64.tar.gz
sudo mv opsbrew /usr/local/bin/
# Verify installation
opsbrew --version
Windows
# Download latest release
curl -L -o opsbrew_Windows_x86_64.zip https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Windows_x86_64.zip
# Extract and add to PATH
# Or use PowerShell:
Expand-Archive -Path opsbrew_Windows_x86_64.zip -DestinationPath C:\opsbrew
# Add C:\opsbrew to your PATH environment variable
From Source
# Clone repository
git clone https://github.com/nghiadaulau/opsbrew.git
cd opsbrew
# Build from source
go build -o opsbrew .
# Install to system
sudo mv opsbrew /usr/local/bin/
# Verify installation
opsbrew --version
Upgrade
Using Go Install (Recommended)
# Upgrade to latest version
go install github.com/nghiadaulau/opsbrew@latest
# Verify new version
opsbrew --version
Using Pre-built Binaries
Linux/macOS
# Download latest release
wget https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Linux_x86_64.tar.gz
# or for macOS: opsbrew_Darwin_x86_64.tar.gz
# Stop any running opsbrew processes
pkill opsbrew
# Backup current version (optional)
sudo cp /usr/local/bin/opsbrew /usr/local/bin/opsbrew.backup
# Extract and replace
tar -xzf opsbrew_Linux_x86_64.tar.gz
sudo mv opsbrew /usr/local/bin/
# Verify new version
opsbrew --version
Windows
# Download latest release
curl -L -o opsbrew_Windows_x86_64.zip https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Windows_x86_64.zip
# Stop any running opsbrew processes
taskkill /F /IM opsbrew.exe
# Extract and replace
Expand-Archive -Path opsbrew_Windows_x86_64.zip -DestinationPath C:\opsbrew -Force
From Source
# Pull latest changes
cd opsbrew
git pull origin main
# Rebuild
go build -o opsbrew .
# Replace existing installation
sudo mv opsbrew /usr/local/bin/
# Verify new version
opsbrew --version
Uninstall
Remove Binary
# Remove the binary
sudo rm /usr/local/bin/opsbrew
# Verify removal
which opsbrew
Remove Configuration (Optional)
# Remove global config
rm ~/.opsbrew.yaml
# Remove per-repo configs (if any)
find . -name "opsbrew.yaml" -delete
Shell Completions
Bash
# Generate bash completion
opsbrew completion bash > ~/.local/share/bash-completion/completions/opsbrew
# Or add to ~/.bashrc
echo 'source <(opsbrew completion bash)' >> ~/.bashrc
source ~/.bashrc
Zsh
# Generate zsh completion
opsbrew completion zsh > ~/.zsh/completions/_opsbrew
# Or add to ~/.zshrc
echo 'source <(opsbrew completion zsh)' >> ~/.zshrc
source ~/.zshrc
Fish
# Generate fish completion
opsbrew completion fish > ~/.config/fish/completions/opsbrew.fish
PowerShell
# Generate PowerShell completion
opsbrew completion powershell | Out-String | Invoke-Expression
# Add to profile for persistence
opsbrew completion powershell > $PROFILE
Configuration
Global Configuration
# Create global config
cat > ~/.opsbrew.yaml << 'EOF'
ui:
confirm: false
verbose: false
brew:
recipes: {}
git:
default_branch: main
sync_strategy: rebase
kubernetes:
default_namespace: default
context_timeout: 30s
EOF
Per-Repository Configuration
# Create repo-specific config
cat > opsbrew.yaml << 'EOF'
ui:
confirm: true
verbose: true
brew:
recipes:
deploy:
description: "Deploy to production"
commands:
- "kubectl apply -f k8s/"
- "kubectl rollout status deployment/app"
git:
default_branch: develop
sync_strategy: merge
EOF
Troubleshooting
Common Issues
Permission Denied
# Fix permissions
sudo chmod +x /usr/local/bin/opsbrew
Command Not Found
# Check if binary exists
ls -la /usr/local/bin/opsbrew
# Check PATH
echo $PATH
# Add to PATH if needed
export PATH=$PATH:/usr/local/bin
Version Issues
# Check current version
opsbrew --version
# Check available versions
git tag -l | grep "^v" | sort -V
# Install specific version
go install github.com/nghiadaulau/opsbrew@v1.0.0
Build Issues
# Clean and rebuild
go clean
go mod download
go build -o opsbrew .
Verification
After installation, verify everything works:
# Check version
opsbrew --version
# Check help
opsbrew --help
# Test git commands
opsbrew git status
# Test k8s commands
opsbrew k8s kctx
# Test file commands
opsbrew file backup README.md
# Test brew commands
opsbrew brew list
Package Managers (Future)
Homebrew (macOS/Linux)
# When Homebrew tap is available
brew tap nghiadaulau/opsbrew
brew install opsbrew
Chocolatey (Windows)
# When Chocolatey package is available
choco install opsbrew
Snap (Linux)
# When Snap package is available
sudo snap install opsbrew
Development Installation
For developers who want to work on opsbrew:
# Clone repository
git clone https://github.com/nghiadaulau/opsbrew.git
cd opsbrew
# Install dependencies
go mod download
# Build
go build -o opsbrew .
# Run tests
go test ./...
# Install development version
go install .
Security
Verify Checksums
# Download checksums
wget https://github.com/nghiadaulau/opsbrew/releases/latest/download/checksums.txt
# Verify downloaded binary
sha256sum -c checksums.txt
GPG Verification (Future)
When GPG signatures are available:
# Import GPG key
gpg --keyserver keyserver.ubuntu.com --recv-keys <KEY_ID>
# Verify signature
gpg --verify opsbrew_Linux_x86_64.tar.gz.sig
Release Guide
This project uses GoReleaser for automated releases.
How to Create a Release
1. Create and Push a Tag
# Create a new tag
git tag v1.0.0
# Push the tag to GitHub
git push origin v1.0.0
2. Automated Release Process
When you push a tag starting with v* (e.g., v1.0.0, v1.2.3), the GitHub Actions workflow will automatically:
-
Build binaries for multiple platforms:
- Linux (amd64, arm64)
- macOS (amd64, arm64)
- Windows (amd64)
-
Create archives:
.tar.gzfor Linux/macOS.zipfor Windows
-
Generate checksums for verification
-
Create a GitHub Release with:
- Release notes from git commits
- All binary artifacts
- Checksums file
3. Release Artifacts
Each release will include:
opsbrew_Linux_x86_64.tar.gz
opsbrew_Linux_arm64.tar.gz
opsbrew_Darwin_x86_64.tar.gz
opsbrew_Darwin_arm64.tar.gz
opsbrew_Windows_x86_64.zip
checksums.txt
4. Installation from Release
Users can download and install from releases:
# Download for Linux
wget https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Linux_x86_64.tar.gz
tar -xzf opsbrew_Linux_x86_64.tar.gz
sudo mv opsbrew /usr/local/bin/
# Download for macOS
wget https://github.com/nghiadaulau/opsbrew/releases/latest/download/opsbrew_Darwin_x86_64.tar.gz
tar -xzf opsbrew_Darwin_x86_64.tar.gz
sudo mv opsbrew /usr/local/bin/
Configuration
The release process is configured in .goreleaser.yml:
- Builds: Multi-platform binary builds
- Archives: Tar.gz and zip formats
- Checksums: SHA256 checksums for verification
- Changelog: Auto-generated from git commits
- Release: GitHub release creation
Future Enhancements
The following features are commented out in .goreleaser.yml and can be enabled when needed:
Homebrew Tap
brews:
- name: opsbrew
homepage: "https://github.com/nghiadaulau/opsbrew"
repository:
owner: nghiadaulau
name: homebrew-tap
Package Managers (DEB/RPM)
nfpms:
- maintainer: "your-email@example.com"
formats:
- deb
- rpm
Docker Images
dockers:
- image_templates:
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
Manual Release (if needed)
If you need to create a release manually:
# Install goreleaser
go install github.com/goreleaser/goreleaser@latest
# Test the release process (dry run)
goreleaser release --snapshot --clean --skip-publish
# Create a real release
goreleaser release --clean
Version Management
- Use semantic versioning:
v1.0.0,v1.1.0,v2.0.0 - Version information is embedded in binaries via ldflags
- Changelog is auto-generated from conventional commits
git status
Show the working tree status.
opsbrew git status
git sync
Sync current branch with remote using rebase.
opsbrew git sync
git checkout
Checkout branch with fuzzy finder.
opsbrew git checkout [branch]
k8s kctx
Switch Kubernetes context with fuzzy finder.
opsbrew k8s kctx
k8s kns
Switch Kubernetes namespace with fuzzy finder.
opsbrew k8s kns
k8s khpa
Manage HPA (Horizontal Pod Autoscaler).
opsbrew k8s khpa list
opsbrew k8s khpa set-min my-hpa 2 -n production
opsbrew k8s khpa set-max my-hpa 10 -n production
k8s kscale
Scale Kubernetes resources.
opsbrew k8s kscale deployment my-app 3 -n production
file open
Open file with default editor.
opsbrew file open config.yaml
file backup
Create backup of file.
opsbrew file backup config.yaml
file find
Find files by name or pattern.
opsbrew file find "*.yaml"
brew
Manage and run command recipes/macros.
opsbrew brew save my-workflow
opsbrew brew run my-workflow
opsbrew brew list
init
Initialize a new project from template.
opsbrew init github-actions
opsbrew init k8s-deployment
completion
Generate completion script.
opsbrew completion bash
opsbrew completion zsh