-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: --directories #169
Comments
What is the use case?
|
It can be used in the same way as I also use the |
I'm kind of wishy washy on this. What I'm looking for is a use case. i.e., You run |
Indeed, I generally feed such output to fuzzy searchers such as |
Is |
Indeed, it isn't. It is around 2.5 times slower than |
This is my expectation. I actually wrote
Right, but the |
Well, EDIT : |
If With that said, I am currently working on moving all of the ignore code out into its own library. When that's done, it would be relatively straight-forward to build your own tool that searches files/directories and respects ignore rules. I think at the end of the day, the |
I know this is rather old, but I just wanted to comment that the ripgrep file search and the directory workaround search are both faster than find for me, on |
@therockmandolinist Yeah, since my earlier comments the directory iterator in ripgrep became parallelized, so it is indeed possible that it is faster than |
A note for posterity using OS X: if you get |
Thanks @braham-snyder for the tip, that helped. I also found that uniq requires duplicates to be adjacent to one another and I was getting many duplicates with this call. You can solve that with So I found an awk snippet which does uniq's functionality for non-adjacent matches and has a happy benefit of being even faster than So combining the two tips above I can now use rg to get dir globbing that respects my
|
This is more idiomatic, more portable, and possibly faster:
zsh only, obv edit: Actually, i'm sorry, i over-looked that you wanted the 'streaming' behaviour — in that respect it may not meet your needs. |
@okdana While it does run slightly faster, it has to wait until the full list is generated to return, so it suffers the same downside as Edit It also uses a huge amount of memory |
Yeah, i caught that right after i submitted it. Sorry, wasn't paying enough attention. |
@chrisjohnson |
Sorry if this is a dumb question, but seeing as some of you use FZF, what is the exact function/command alias you guys use for fzf + rg directory traversal? My current fzf aliases are (hoping this might help others): export FZF_DEFAULT_COMMAND='rg -L --files --hidden'
# fe [FUZZY PATTERN] - Open the selected file with the default editor
# - Bypass fuzzy finder if there's only one match (--select-1)
# - Exit if there's no match (--exit-0)
fe() {
local files
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
}
# fd [FUZZY PATTERN] - Open the selected folder
# - Bypass fuzzy finder if there's only one match (--select-1)
# - Exit if there's no match (--exit-0)
fd() {
local file
local dir
file=$(fzf +m -q "$1") && dir=$(dirname "$file") && cd "$dir"
}
if [[ $(uname) == "Darwin" ]]; then
# dirname on OS X behaves funky, get gdirname via
# brew install coreutils
export dirname_command="gdirname"
else
export dirname_command="dirname"
fi
# Faster compgen
_fzf_compgen_dir() {
rg --hidden --files --null "$1" 2 > /dev/null | xargs -0 "$dirname_command" | awk '!h[$0]++'
} I would love for "fd" to be like fe except only show dir names, instead of dir and file names. |
https://github.com/junegunn/fzf#settings Just worked with the author of fzf to finalize this suggested fix. If you look at my PR here you can see a non-ruby version but honestly the ruby version is much better because it walks up the dir chain for every file to ensure the path is added all the way up, plus it's faster than the awk approach. |
Hi there,
I read the blog http://blog.burntsushi.net/ripgrep/#gathering-files-to-search and it seams that the ripgrep directory traversal is very efficient (http://burntsushi.net/rustdoc/walkdir/). This could be used for a feature like
--files
, but for directories (while coping with the ignore rules , e.g. rg --hidden --directories
).Thank you for that amazing tool,
Kind regards
EDIT: formatting
The text was updated successfully, but these errors were encountered: