GithubHelp home page GithubHelp logo

neuroradiology / fzf-live-repl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pawelduda/fzf-live-repl

0.0 1.0 0.0 360 KB

Turn your fzf into a live REPL

License: The Unlicense

Shell 100.00%

fzf-live-repl's Introduction

๐Ÿš€ fzf-live-repl ๐Ÿš€

This hacky one-liner turns your fzf into a live REPL. There is not much to explain, see it for yourself. Please note that I will be adding more examples as I come up with them. You are also welcome to contribute them yourself by creating an issue or a pull request.

Featured in my blog post

See also: fzf-launch - open any file directly from command line with a command of your choice

How?

By abusing the --preview flag of fzf. It allows an arbitrary command to be executed as the query changes. The {q} is then being substituted by your typed query. After exiting fzf by pressing enter, the --print-query flag ensures that the typed query will be printed to stdout.

WARNING!

Always be careful what you set the --preview flag to! Imagine setting rm -rf and then typing * as the query string!. I take no responsibility if you break anything!

ONLY USE THIS FOR COMMANDS WHICH ARE READ-ONLY!

ALWAYS KNOW WHAT YOU'RE TYPING/PASTING!

Examples

Live awk preview

$ echo '' | fzf --print-query --preview 'echo "a\nb\nc\nd" | awk {q}'

live-awk-preview

Peek into contents of a directory

$ echo '' | fzf --preview 'ls {q}'

fzf-ls

Execute a Ruby script

$ echo '' | fzf --print-query --preview 'ruby -e {q}'

fzf-ruby

Instantly browse manpages (and find the relevant flag as you type the command - TODO)

$ echo '' | fzf --preview 'man {q}'

Execute a Python script

$ echo '' | fzf --print-query --preview 'python -c {q}'

fzf-live-repl's People

Contributors

pawelduda avatar srijanshetty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.