Live data from Hacker News

Fzf – the basics part 1 – layout

qmacro.org

31–40 of 40 posts

Re: Fzf – the basics part 1 – layout

#31
post #14

My favorite ~/.gitconfig [alias] that uses fzf: # Allows you to easily pick what to rebase frbi = "!f() { git rebase -i $(git log --pretty=oneline --color=always | fzf --ansi | cut -d ' ' -f1)^ ; }; f" Then just do: git frbi

Here's some additional FZF Git love posted by junegunn a while back. https://junegunn.kr/2016/07/fzf-git/

Re: Fzf – the basics part 1 – layout

#32
post #29

I love fzf as well. I use it with the npm package manager to select the script to run (we have an app with 20+ scripts): npmrf () { local script script=$(cat package.json | jq -r '.scripts | keys[] ' | sort | fzf) && npm run $script } Another usecase is tracking hours with Clockify. I was frustrated opening up the web everytime, so I wrote a script using fzf, httpie and jq. Love it now. [1] [1]: https://marcel.is/tra…

That's a great idea, thanks. Do you know how to get it to show the preview window with the script value? Sometimes I need to explore which script task I need based on what it does

Re: Fzf – the basics part 1 – layout

#34
post #29

I love fzf as well. I use it with the npm package manager to select the script to run (we have an app with 20+ scripts): npmrf () { local script script=$(cat package.json | jq -r '.scripts | keys[] ' | sort | fzf) && npm run $script } Another usecase is tracking hours with Clockify. I was frustrated opening up the web everytime, so I wrote a script using fzf, httpie and jq. Love it now. [1] [1]: https://marcel.is/tra…

That's a great idea, thanks. Do you know how to get it to show the preview window with the script value? Sometimes I need to explore which script task I need based on what it does

Yeah, that would be nice. I don't know though from the top of my head.

Re: Fzf – the basics part 1 – layout

#35

Earlier quoted context omitted.

I use z[0] in place of autojump. That way I don't need to install Python solely for autojump. This is especially true, when sshing to servers. [0]: https://github.com/rupa/z

I've moved to https://github.com/ajeetdsouza/zoxide/ from z, as it can also show you a list of matching directories using fzf

    # https://github.com/junegunn/fzf/wiki/Examples#integration-with-z
    # like normal z when used with arguments but displays an fzf prompt when used without.

    unalias z 2> /dev/null

    z() {
      [ $# -gt 0 ] && _z "$*" && return
      cd "$(_z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')"
    }

Re: Fzf – the basics part 1 – layout

#36
post #16

Fzf might be my most used command line utility. That and autojump (alias to j).

I'm a big fan of autojump but switch to the Rust port recently. https://github.com/ajeetdsouza/zoxide

Damn, there seems to be so many Rust cmd tools recently that it's hard to keep up with what's new ;)

Thanks, I was using https://github.com/badmotorfinger/z for powershell before. I will check it out.

Re: Fzf – the basics part 1 – layout

#37
post #29

I love fzf as well. I use it with the npm package manager to select the script to run (we have an app with 20+ scripts): npmrf () { local script script=$(cat package.json | jq -r '.scripts | keys[] ' | sort | fzf) && npm run $script } Another usecase is tracking hours with Clockify. I was frustrated opening up the web everytime, so I wrote a script using fzf, httpie and jq. Love it now. [1] [1]: https://marcel.is/tra…

That's a great idea, thanks. Do you know how to get it to show the preview window with the script value? Sometimes I need to explore which script task I need based on what it does

You could do something like this (not super thoroughly tested):

  npmrf () {
    local script
    script=$(jq -r '.scripts | to_entries[] | "\(.key) => \(.value)"' 
It uses jq's to_entries to pull out the script/command key pairs and then just cuts out the script name after you choose the command (assumes the command name doesn't have spaces).

Re: Fzf – the basics part 1 – layout

#38

plocate is a very fast mlocate alternative that uses indexes over trigrams and io_uring for reading the database. With fzf you can have a pretty fast fuzzy search over your entire indexed disk. FZF_DEFAULT_COMMAND="plocate ''" \ fzf --bind "change:reload:plocate {q} || true" \ --ansi --phony --query "" --preview 'file {}' --bind '?:preview:cat {}' https://plocate.sesse.net/ I don't actually use it. It's more a fun ha…

thanks for this, I just replaced my mlocate. absolutely unreal. seems io_uring makes all the difference.

Hi,

I'm the author of plocate. io_uring is not the primary part of the difference; it makes for a pretty good win if you have rotating disks (especially when you have many matches to test), but on SSD, it's pretty much inconsequential. The biggest difference really comes from the use of an index, as opposed to matching every single candidate against the pattern.

Re: Fzf – the basics part 1 – layout

#39
post #23
post #2

fzy[1] is a less bloated alternative, written in C. fzf is neat, but it does too much. [1]: https://github.com/jhawthorn/fzy

fzf never struck me as the slightest bit slow. What am I doing wrong? You can configure it with an external previewer that can of cause be arbitrarily slow or bloated but you can hardly fault fzf for that.

In my experience fzf actually feels faster simply because it’s able to begin populating the output list before it finishes reading the input list. This means you get selection options immediately, whereas with fzy there can be a delay. This is particularly noticeable when working with large inputs (e.g. anything in the Linux kernel)

Re: Fzf – the basics part 1 – layout

#40
post #8

This thing is magical! I use it as a quick scientific paper finder. Basically have a folder with, probably thousands by now, papers (each file's name contains paper title, authors, year, journal) and by typing a couple words can fuzzy search for stuff by whatever fields. It also works incredibly nicely with vim as a fuzzy search for either files or phrases within files.

A nice, I do the same but I convert all books, papers and powerpoints to pdf files with a rondom name or i use a hash of the content as name. Then in use ripgrepall with fzf to search for the information i'm looking for.
Post reply on HN