Skip to content

how to integrate ripgrep with fzf by using match positions? #2580

Closed Answered by joelpeapen
joelpeapen asked this question in Q&A
Discussion options

You must be logged in to vote

found it. maybe this could be in a tips section.

function rgf() {
    c="rg --column -nS --no-heading --color=always"
    a="$(fzf --bind "change:reload:$c {q} || true" \
        --ansi --reverse --preview '' --header 'Search in files')"
    if [[ -n $a ]]; then
        IFS=':' read -r file line char _ <<< "$a"
        "$EDITOR" "$file" +"$line" -c "norm ${char}lh"
        cd "$(dirname "$(readlink -f "$file")")"
    fi
}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@BurntSushi
Comment options

@joelpeapen
Comment options

@joelpeapen
Comment options

Answer selected by joelpeapen
@BurntSushi
Comment options

@BurntSushi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants