sharkdp / fd Goto Github PK
View Code? Open in Web Editor NEWA simple, fast and user-friendly alternative to 'find'
License: Apache License 2.0
A simple, fast and user-friendly alternative to 'find'
License: Apache License 2.0
Add a homebrew formula for fd
.
For example:
fd todo
fd apache /var/log
fd
as an alternative for ls -R
: fd
fd -HI ...
.xargs
: fd -0 ... | xargs -0 du -h
-a
or by providing an absolute path as destination)fd pat
-> case-insensitive search for pat (or PAT, or Pat, ...)fd Pat
-> case-sensitive search for PatThis code is cross-platform save for the "executable file" check, which is only relevant on unix systems, and is done for the sole purpose of color-coding output lines.
I managed to make your code run on windows by adding conditional compilation operators to
use std::os::unix::fs::PermissionsExt;
and to redefine the is_executable
function on non-Linux systems.
clap has an option to show a more detailed help message if fd --help
is called (as compared to fd -h
):
We could use this to provide a more detailed help text for fd
.
this needs a 'static
lifetime or the static_in_const
feature, see #35897
changed ROOT_DIR assignment and compiles just fine.
static ROOT_DIR : &'static str = "/";
Mention in doc you need rust version 1.17.0. I got compile errors using 1.16.0.
I'd like a new option --type d
for matching only directories and --type f
for matching only files.
For example:
I think that the README should specifically mention that the regex search is faster(that's because the regex is slow in find
).
The actual search is slower(it seems to imply that the find in general is faster).
Here is a more realistic usage of find
, on an SSD(all runs are on warm cache):
time find -name '*.cpp'
...
real 0m0.447s
user 0m0.044s
sys 0m0.220s
And because fd
uses patterns, it would look like this:
time fd '.*\.cpp$'
...
real 0m2.353s
user 0m0.100s
sys 0m1.240s
Weird, I just tested(while writing this) with -iregex
and I got this:
time find -iregex '.*\.cpp$'
...
real 0m0.667s
user 0m0.128s
sys 0m0.400s
walkdir
is a recursive directory traversing crate with no redundant operations (stat etc). It's also used by the award-winning ripgrep
tool.
We always wanted the speed without complexity; how about reusing existing code instead of hand rolling one?
Please provide --version
option to print the version.
$ fd --version
1.1.0
fd
does not exit cleanly when the stdout pipe is broken:
$ fd | head
[snip 10 lines]
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', /checkout/src/libstd/io/stdio.rs:693
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Currently, the colours are only based on path: directories are a different colour, executable files are a different colour, etc.
It would be nice to highlight which parts of the path matched the current regexp. This would help understand why a given file matched the regexp.
For example:
> fd -e rs
src/fshelper/mod.rs
src/lscolors/mod.rs
src/main.rs
Right now, this is only possible by searching for \.rs$
.
Title is self-explanatory.
fd pattern /non-existent
should throw an error. Currently, it silently falls back to $CWD
Suggestion: Support .ignore files using same format as Ripgrep and The Silver Searcher ( rg and ag ).
I tried to run the test shell script in macOS and it returns this:
⋊> ~/c/r/fd on master ⨯ sh tests/test.sh 14:25:13
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
mktemp [-d] [-q] [-u] -t prefix
> cd /folder/with/lots/of/files
> time fnd jpg$ > /dev/null
fnd jpg$ > /dev/null 7,79s user 0,72s system 99% cpu 8,521 total
> time find -iname '*.jpg' > /dev/null
find -iname '*.jpg' > /dev/null 0,35s user 0,40s system 99% cpu 0,757 total
> time find -iregex '.*jpg$' > /dev/null
find -iregex '.*jpg$' > /dev/null 1,12s user 0,40s system 99% cpu 1,531 total
In order to pipe the output to other programs (or write to files)
Try to replace Walk
by WalkParallel
and investigate potential performance benefits / usability downsides (unsorted output).
(via @BurntSushi on reddit)
On ubuntu 16.04 Linux pollux 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Attempted to install
cargo install --git https://github.com/sharkdp/fd --verbose
That fd would be installed to my path without a fuss, much like I experienced on my Mac
Compiling fd v1.1.0 (https://github.com/sharkdp/fd#54f33e52)
Running `rustc /home/eric/.cargo/git/checkouts/fd-9d671bc4b2af369e/54f33e5227e928fece1ed917749b6b4d4d23955f/src/main.rs --crate-name fd --crate-type bin -C opt-level=3 -C metadata=0ffa62fa1d203255 --out-dir /tmp/cargo-install.qbpI7XATIUGN/release --emit=dep-info,link -L dependency=/tmp/cargo-install.qbpI7XATIUGN/release/deps --extern ansi_term=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libansi_term-aa5dcc2affa8dc75.rlib --extern regex=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libregex-59f42a2a673f3a9d.rlib --extern clap=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libclap-bb4314a2ee3c5d44.rlib --extern ignore=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libignore-2e1cde877880acb9.rlib --extern atty=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libatty-acdf806defe52cbb.rlib`
error: no method named `split_off` found for type `std::string::String` in the current scope
--> /home/eric/.cargo/git/checkouts/fd-9d671bc4b2af369e/54f33e5227e928fece1ed917749b6b4d4d23955f/src/lscolors/mod.rs:136:63
|
136 | let extension = String::from(pattern).split_off(2);
| ^^^^^^^^^
error: no method named `split_off` found for type `std::string::String` in the current scope
--> /home/eric/.cargo/git/checkouts/fd-9d671bc4b2af369e/54f33e5227e928fece1ed917749b6b4d4d23955f/src/lscolors/mod.rs:140:62
|
140 | let filename = String::from(pattern).split_off(1);
| ^^^^^^^^^
error: aborting due to 2 previous errors
error: failed to compile `fd v1.1.0 (https://github.com/sharkdp/fd#54f33e52)`, intermediate artifacts can be found at `/tmp/cargo-install.qbpI7XATIUGN`
Caused by:
Could not compile `fd`.
Caused by:
process didn't exit successfully: `rustc /home/eric/.cargo/git/checkouts/fd-9d671bc4b2af369e/54f33e5227e928fece1ed917749b6b4d4d23955f/src/main.rs --crate-name fd --crate-type bin -C opt-level=3 -C metadata=0ffa62fa1d203255 --out-dir /tmp/cargo-install.qbpI7XATIUGN/release --emit=dep-info,link -L dependency=/tmp/cargo-install.qbpI7XATIUGN/release/deps --extern ansi_term=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libansi_term-aa5dcc2affa8dc75.rlib --extern regex=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libregex-59f42a2a673f3a9d.rlib --extern clap=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libclap-bb4314a2ee3c5d44.rlib --extern ignore=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libignore-2e1cde877880acb9.rlib --extern atty=/tmp/cargo-install.qbpI7XATIUGN/release/deps/libatty-acdf806defe52cbb.rlib` (exit code: 101)
I am still getting my bearings with rust but I will do my best to help -- this tool is a pleasure to use. Thanks for your work on this project thus far! 👍
This might be a rare use case. But fd is 5x slower then find on a VirtualBox shared folder for me.
For the same data set fd is faster native. Also inside Virtualbox normal (non-shared) folder fd is faster.
For example: fd's -I/--no-ignore
vs ripgrep's -u/--unrestricted
.
(via DebuggingPanda on reddit)
Thanks for a great plugin!
fd
doesn't use color when piping, however it can be useful. My usecase is for use with lotabout/skim.
ripgrep provides this behaviour with: rg --color=always
Hi! I'm not entirely sure, but I think I've experienced a bug parsing a git ignore file. I did (with 1.1):
$ cd /tmp/
$ git clone --depth 1 http://code.qt.io/git/qt/qtbase
Cloning into 'qtbase'...
remote: Counting objects: 22136, done.
remote: Compressing objects: 100% (16582/16582), done.
remote: Total 22136 (delta 5296), reused 16146 (delta 3446)
Receiving objects: 100% (22136/22136), 55.12 MiB | 2.70 MiB/s, done.
Resolving deltas: 100% (5296/5296), done.
$ cd qtbase/examples/
$ fd regular
widgets/doc/images/regularexpression-example.png
widgets/doc/src/regularexpression.qdoc
$ fd --no-ignore regular
widgets/tools/regularexpression
widgets/tools/regularexpression/regularexpressiondialog.h
widgets/tools/regularexpression/regularexpression.qrc
widgets/tools/regularexpression/regularexpression.pro
widgets/tools/regularexpression/regularexpressiondialog.cpp
widgets/doc/images/regularexpression-example.png
widgets/doc/src/regularexpression.qdoc
The .gitignore file of that repository may be a bit complex since, if I understand it properly, it uses a glob to add some files that later on are removed with a negative glob. I'm not entirely sure of the rules for it, but to me that is a bug in fd
, since the files shown with --no-ignore
are not ignored by git.
Thank you!
Possible options are [updated on 2017-06-05]:
--hidden
(-h
is for --help
...)=> Done already, -H
can be used (alongside --hidden
) for searching hidden directories.
~/.config/fdrc
) where defaults (such as search_hidden=true
) can be set=> As discussed below, this will not be implemented for now. Aliases (such as alias fd="fd -HI"
).
In particular, OsStr
to String
conversions may fail.
Quote by @BurntSushi on reddit:
You are converting all paths to strings before searching, which will probably blow up on you in some cases when file paths don't contain valid UTF-8. (And it does happen, because I had a similar bug in my own code.) On *nix at least, you can extract the raw &[u8] from a file path safely and then feed that into a regex::bytes::Regex (instead of regex::Regex).
I'm a ripgrep user on windows (git bash) and ripgrep makes it really easy to install: https://github.com/BurntSushi/ripgrep#installation. In my case I just did $ choco install ripgrep
Would be great if fd would also provide binary downloads with every release:
ripgrep has first class support on Windows, Mac and Linux, with binary downloads available for every release.
I guess ripgrep has some automatic build tooling for this.
Hi, thanks for this project! Adding bfs search would benefit interactively directory navigating.
.gitignore
files in directories and ignore respective files.git
folders (and similar for other VCS)A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.