Recipes

21 pipeline recipes combining CLI tools for real-world tasks.

Interactively find and open a file

fd --type f | fzf --preview 'bat --color=always {}' | xargs nvim

fd finds files recursively, fzf provides fuzzy interactive selection with bat-powered syntax-highlighted preview, then opens the chosen file in neovim

Find and preview recently modified files

fd --type f --changed-within 2d | fzf --preview 'bat --color=always --line-range :50 {}'

fd filters to files changed in the last 2 days, fzf lets you browse them with bat previewing the first 50 lines

Search code and preview matches in context

rg --line-number --no-heading 'TODO|FIXME' | fzf --preview 'bat --color=always --highlight-line {2} {1}' --delimiter ':'

ripgrep finds TODO/FIXME comments with line numbers, fzf lets you browse results with bat showing highlighted context around each match

Find function definitions across a codebase

rg --type py 'def \w+' -l | fzf --preview 'rg --color always --context 3 "def \w+" {}'

ripgrep lists Python files containing function definitions, fzf previews matching lines with surrounding context

Fetch and explore a JSON API interactively

curl -s https://api.example.com/data | jq '.' | fzf --preview 'echo {} | jq .'

curl fetches JSON from an API, jq pretty-prints it, fzf lets you browse and filter the output interactively

Flatten nested JSON keys for easy grepping

curl -s https://api.example.com/data | gron | rg 'email' | gron --ungron

gron transforms JSON into discrete assignments making it greppable, ripgrep filters for relevant keys, gron --ungron converts back to JSON

Extract and format specific fields from a JSON API

http GET https://api.example.com/users | jq -r '.[] | [.name, .email] | @tsv'

httpie fetches JSON with a clean syntax, jq extracts name and email fields and formats them as tab-separated values

Interactively browse and checkout git branches

git branch --all --sort=-committerdate | fzf --preview 'git log --oneline --graph -20 {}' | xargs git checkout

Lists branches sorted by recent activity, fzf previews commit history for each branch, then checks out the selected one

Review recent commits with side-by-side diffs

git log --oneline -20 | fzf --preview 'git show {1} | delta --side-by-side'

Shows recent commits in fzf, previews each with delta rendering a side-by-side colored diff

Find and open changed files from a pull request

gh pr diff --name-only | fzf --preview 'bat --color=always {}' | xargs nvim

gh lists files changed in the current PR, fzf lets you browse them with bat preview, then opens the selection in neovim

Find which processes are using the most memory

procs --sortd mem | head -20

procs lists processes sorted by memory usage in descending order, showing the top 20 consumers with a readable colored output

Quickly compare disk usage across mount points

duf --only local && dust -d 1

duf shows a table of local filesystem usage per mount point, then dust visualizes top-level directory sizes as a tree

List files with details and find large directories

eza --long --sort=size --reverse --git | head -30

eza lists files sorted by size (largest first) with git status indicators, permissions, and human-readable sizes

Bulk rename files using a pattern

fd --type f '.jpeg$' | xargs -I{} f2 -f '.jpeg' -r '.jpg' {}

fd finds all .jpeg files recursively, f2 performs a safe batch rename from .jpeg to .jpg with dry-run preview by default

Replace a string across all matching files

rg 'oldFunction' -l | xargs sd 'oldFunction' 'newFunction'

ripgrep finds files containing the old string, sd performs an in-place find-and-replace across all of them

Extract specific columns from command output

ps aux | choose 0 1 10

choose extracts the user, PID, and command columns from ps output, acting as a more ergonomic alternative to awk

Benchmark two commands against each other

hyperfine --warmup 3 'fd --type f' 'find . -type f'

hyperfine runs both commands multiple times with warmup, then displays a statistical comparison of their execution times

Auto-run tests on file changes

fd --type f --extension py | entr -c python -m pytest

fd finds all Python files, entr watches them and re-runs the test suite automatically whenever any file changes, clearing the screen each time

Check DNS resolution across multiple resolvers

doggo example.com A @1.1.1.1 @8.8.8.8 @9.9.9.9

doggo queries the domain against Cloudflare, Google, and Quad9 DNS resolvers simultaneously, displaying results in a clean table

Convert and compress a video for web

ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4

ffmpeg re-encodes video with H.264 at a balanced quality/size ratio and AAC audio, producing a web-friendly MP4

Generate image thumbnails in bulk

fd --extension png --extension jpg | xargs -P4 -I{} convert {} -resize 300x300 thumbs/{}

fd finds all images, xargs runs ImageMagick convert in parallel (4 jobs) to create 300x300 thumbnails in a thumbs directory