Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Turn your fzf into a live REPL (paweldu.dev)
190 points by pawelduda on July 17, 2019 | hide | past | favorite | 27 comments



I obtain a similar thing by adding this snippet to my .zshrc[0]. Notice I use bat[1] and exa[2] as alternative to cat and ls.

This is the result: https://gfycat.com/brokengiantcockerspaniel

[0]: https://github.com/silvanocerza/dotfiles/blob/master/zsh/zsh...

[1]: https://github.com/sharkdp/bat

[2]: https://github.com/ogham/exa


This is really cool. I didn't realize --preview could take something as complex as this.


Nice tips!! bat(1) is fantastic, wow. exa(1) seems neat, but the inconsiderate--and likely deliberate--lack of compatibility with ls(1) flags means I will never use it any time soon... I have decades' worth of aliases, scripts, and reflexive muscle-memory using GNU ls, so it's not even close to being worth the pain of changing.


It's not like your going to delete `ls` - you can have both?

I have a `ll` alias which is use for 80% of my "what's in this folder" ls use - I just changed this alias (and a couple of others) to use exa. I left ls alone: I didn't alias ls to exa.

It's been a good QoL improvement for me, at ~zero cost.


You're right. I can do that. I didn't want to risk starting a flame war by admitting I have twelve main `ls' aliases (twelve unique argv incantations), and that I keep them portable across platforms. LOL. I started doing this about 20 yrs ago. Many times, I will inject them with a zsh or keyboard macro, since I type on a custom keymap on a programmable keyboard. So I didn't want yet another conditional branch in my configuration management. ;) Not sure whether "special" or just demented...


You could try lsd(https://github.com/Peltoche/lsd) instead of exa.


The fzf.vim[0] plugin offers similar capability in vim to give you this: https://asciinema.org/a/171913

[0]: https://github.com/junegunn/fzf.vim


The missing piece I needed to understand this:

> https://github.com/junegunn/fzf

> fzf is a general-purpose command-line fuzzy finder.

> It's an interactive Unix filter for command-line that can be used with any list; files, command history, processes, hostnames, bookmarks, git commits, etc.


Also: https://github.com/kelleyma49/PSFzf, 'A PowerShell wrapper around the fuzzy finder fzf'. I keep on posting this here because it seems so unknown, yet it's so useful.

Just the fact that fzf turns Ctrl-R into something which is actually usable (in comparison with the standard implementation like bash has which requires you to type exact commands from the start). And then all the other goodies which prevent you from having to type way too much cd/tab strokes. Maybe I just rely on fuzzy matching too much but since most software I use daily has it (text editors, IDEs and shells), it's really hard to imagine the amount of time lost before I had it.


Exactly! Then stay tuned for more! I have another article about getting creative with fzf in progress. And another some more ideas that I will not disclose yet because I haven't validated them :)


Very cool. Relevant: https://github.com/akavel/up


Yep, which you can kind-of do with : echo '' | fzf --multi --preview='bash -c {q}' --preview-window=up:70


In fact no need of `: echo '' |` here. Only `: |` is enough.


This looks cool, though running e.g. arbitrary ruby scripts seems kinda dangerous when it executes on every character instead of only when you ask it to.


<shameless-plug> You may also like to have a look at https://github.com/akavel/up as an alternative. It now executes the command only after Enter is pressed (though originally I also went with execution on every keypress). By default it runs shell commands/pipelines, but you can change the contents of SHELL env. variable to write raw ruby, awk, or else.


My exact concern with this. For now I can only recommend using it with read-only commands and not pasting anything into it that you do not fully understand.

Probably will add some security check to prevent user from running destructive commands at some point.


And many other things besides Ruby scripts


Hello HN! I am sorry for the fact that the article is so "raw". I made this blog literally a week ago, without any prior knowledge or plans. If you have any feedback on how to make the site more approachable, please let me know!


The live previews were great, but it took absolutely forever for the command to get typed out before it moved onto the execution! I might suggest speeding up the typing, or just skipping it


Good point. I am new to this and I just wanted to publish it & go to bed. Will fix it later.


I didn't know about these features, this is awesome. Thanks for sharing. I think you have a small typo at the bottom of the page:

Please ____ the repo which will be updated regularly here


Thank you! Will be fixed in a second.


Thank you for sharing! I had no idea what fzf was when I read your post at first, so I was confused. Maybe just a quick intro sentence (with a link) to help set some context. Otherwise awesome!


Hey, pretty cool! Thanks for sharing.


In a familiar fashion, if you use fzf.vim along with ripgrep you can run :Rg without any arguments and get a real time filter on finding any text within your project.

Normally you would run :Rg with a phrase to search for, but leaving it empty and typing it in live is really useful sometimes.

It's really fast too. On my machine running in WSL, it searches through hundreds of files and almost a megabyte of text as fast as I can type.


This is also true with ag and :Ag


Tangentially related, but I've been trying to find a fancy Node/Typescript (either would be great) REPL. By fancy I mean vim bindings (like `set -o vi` in bash), color schemes, and terminal based.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: