3 ms·
Vim universe: fzf – command line fuzzy finder (2019) [video]
- schindlabua 3y agofzf is such an amazing tool. Like yes it can do fuzzy search but it's so hackable and you can do so many unrelated things with it. Because it's also a tool that you can pipe an array of things into, select an element from it, and run a command on that element. Just the other day I needed to scour the git history of a huge project, so I wrote a function that first selects a file by running fzf, and then lets me see the git history of any single line of that file by running fzf again. gblame2 () { local file=$(fzf) cat "$file" | awk '{printf("%5d %s\n", NR, $0)}' | fzf --layout reverse --preview-window up --preview "echo {} | awk '{print \$1}' | xargs -I _ sh -c \"git log --color -L_,'+1:${file}'\"" } chatgpt cooked that up for me in 5 minutes, saved me many many hours.
- overtomanu 3y agofound out that this has problems when file name has underscore (_) Better use some long rare string as place holder for xargs gblame2 () { local file=$(fzf) cat "$file" | awk '{printf("%5d %s\n", NR, $0)}' | fzf --layout reverse --preview-window up --preview "echo {} | awk '{print \$1}' | xargs -I __XZY__ sh -c \"git log --color -L__XZY__,'+1:${file}'\"" }
- 1-more 3y agoI've shared it before but my tool for switching git branches based on time (it's called flog because I always read reflog as re-flog not ref-log) flog () { branch="$( git branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)%09%(subject)" \ | column -ts $'\t' \ | fzf \ | sed 's/.*ago \+\([^ ]*\) .*/\1/' )" git co $branch || ( echo -n "git co $branch" | pbcopy ) } I have a much longer one for switching between PRs requesting my review and previewing them while I do it. edit: funny story, I went to add 4 spaces to the start of each line and it turns out I did the same thing last time and my autocomplete got it for me which flog | sed 's/^/ /' | pbcopy
- nicbarth 3y agoCool idea! I actually do something similar albeit without sorting. The idea is if you check out a remote branch it'll track it. gbb() { eval $(echo git checkout "$(git branch --all \ | fzf --height 10 \ | tr -d '[:space:]' \ | tr -d '*' \ | sed 's/remotes\//\-\-track /g')") }
- jonfw 3y agoFZF is the best, I've got a variety of scripts that use FZF as their UI, for everything from logging into a team member's meeting room to targeting a cluster. I use FZF for my command line history search and save 10000 lines of shell history, and now I can find every weird jq, kubectl, awk, etc. command I've ever ran to get me going on some of the syntax quickly. fuzzy search is the best UI for navigating lists ever
- jaygreco 3y agoI love fzf. The fuzzy reverse-search alone is worth a lot to me.
- javier_e06 3y agoThis tool rocks but is intimidating.. I clone the project and the install script is a bash executable without the .sh suffix and is 310 lines long Sure go ahead execute this thing and cross your fingers.. I use powerline-shell and git auto completion for branches and such and I was sweating this thing was going to shoot me. They added a Docker file for the scared cats like me so I can see it in action without messing my environment. I verified that it left my .bashrc alone and does not encroached <so far> with tmux and bash key bindings. So I installed and I can tell it projects my brain birds-eye view into the screen. The *<TAB> keybinding is the best. Great find. Thanks!
- sjkoelle 3y agoit changed my life