Replies: 1 comment
|
You do not need to 1. Ripgrep + fzf (search under another directory)
# usage: rfg [root_dir] [initial_query]
rfg() {
local root="${1:-.}"
local query="${2:-}"
shift $(( $# > 0 ? 1 : 0 ))
shift $(( $# > 0 ? 1 : 0 )) 2>/dev/null
local rg_base=(rg --column --line-number --no-heading --color=always --smart-case)
FZF_DEFAULT_COMMAND="${rg_base[*]} -- '$query' '$root'" \
fzf --ansi \
--disabled \
--query "$query" \
--bind "change:reload:sleep 0.05; ${rg_base[*]} -- {q} '$root' || true" \
--delimiter : \
--preview 'bat --style=numbers --color=always --highlight-line {2} {1}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
}Example: stay in rfg ~/src/my-project "TODO"Key point from the walkthrough’s 2. Pure fzf file walk under another rootWhen you are not using fzf --walker-root=/path/to/dir
# multiple roots:
fzf --walker-root=/path/one /path/two3. Combined pattern (files from root, then filter)root=~/src/my-project
fzf --walker-root="$root" --bind "ctrl-g:reload(rg --files '$root')"Doc suggestionA short subsection on the walkthrough would help:
That matches the “one step at a time” style of the article without forcing a |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello!
First of all, I wanted to say that I enjoyed reading the Ripgrep integration, a walkthrough! I loved the way you explained things by going 1 step at a time from the simplest call to the more and more complex ones.
However, I've noticed that the whole article basically builds a complex command that, while working nicely, does so only under current directory (recursively). This means that if a user is interested in searching only under a specific dir - they have to
cdthere first and that's... not comfy.Instead, I'd like to stay in my current directory, but be able to search under another directory.
fzfhas--walker-rootarg for that.ripgrepexpects the path to just be the 2nd arg.Could you, please, improve the article by adding support and explanation of setting search path?
All reactions