Skip to content

Instantly share code, notes, and snippets.

@MaherSaif
Forked from hopsoft/README.md
Created March 29, 2024 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaherSaif/b2af3defd43b05ec39b2370e2763d5e1 to your computer and use it in GitHub Desktop.
Save MaherSaif/b2af3defd43b05ec39b2370e2763d5e1 to your computer and use it in GitHub Desktop.
stdin → fzf with preview

stdin → fzf with preview

Setup

  1. Add the script below to your PATH
  2. Pipe anything from stdin to infzf
  3. Enjoy!

Usage

ps aux | infzf

CleanShot 2024-03-29 at 03 37 21@2x

#!/usr/bin/env ruby
require "tempfile"
Tempfile.create do |file|
file.write $stdin.read
file.flush
preview = "rg --pretty --fixed-strings --before-context=3 --after-context=6 {} #{file.path}"
`fzf --ansi --preview=\"#{preview}\" --preview-window=wrap,60% < #{file.path}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment