Skip to content

Instantly share code, notes, and snippets.

@treatmesubj
Created November 26, 2025 15:45
Show Gist options
  • Select an option

  • Save treatmesubj/1c325d7715a2386cc0c8efdc3e25a1ae to your computer and use it in GitHub Desktop.

Select an option

Save treatmesubj/1c325d7715a2386cc0c8efdc3e25a1ae to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
grepi() {
# interactive case-insensitive grep
# grepi file.txt
local data=${1:-'-'}
if [ "$data" = "-" ]; then
local data=$(mktemp)
cp /dev/stdin "$data"
fi
query=$(true | fzf --prompt 'grep -i ' --print-query \
--preview-window='down:80%' \
--preview "grep -i {q} --color=always \"$data\""
)
echo "grep -i \"$query\" \"$data\"" >&2
grep -i "$query" "$data"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment