Giter Club home page Giter Club logo

fd's People

Contributors

alexmaco avatar ato2207 avatar dependabot[bot] avatar detegr avatar detly avatar djrhails avatar doxterpepper avatar ethsol avatar fallenwarrior2k avatar fusillicode avatar jcaplan avatar marionebl avatar matematikaadit avatar miles170 avatar mmstick avatar mookid avatar niklasmohrin avatar pramodbisht avatar psinghal20 avatar reima avatar rootbid avatar scottchiefbaker avatar sharkdp avatar sitiom avatar skoriop avatar stevepentland avatar tavianator avatar tmccombs avatar vijfhoek avatar yyogo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fd's Issues

Add usage examples to the README

For example:

  • Searching for a substring: fd todo
  • Searching for a substring in another location: fd apache /var/log
  • Use fd as an alternative for ls -R: fd
  • Searching all files (including hidden and ignored files): fd -HI ....
  • Searching for a file extension (see also #56)
  • Piping output to xargs: fd -0 ... | xargs -0 du -h
  • Show absolute paths (either via -a or by providing an absolute path as destination)

Smart case

  • fd pat -> case-insensitive search for pat (or PAT, or Pat, ...)
  • fd Pat -> case-sensitive search for Pat

Add windows compatibility

This 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.

compile fails

this needs a 'static lifetime or the static_in_const feature, see #35897

changed ROOT_DIR assignment and compiles just fine.

69c69
< static ROOT_DIR : &str = "/";

static ROOT_DIR : &'static str = "/";

Reproducible benchmarks

For example:

  • Generate a lot of dummy files / directories in a controlled way by a shell script and run specific benchmarks within this test folder.
  • Clone a certain (big) repository and run benchmarks within this repository (this is not 100% reproducible).

The benchmarks are misleading

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

Switch to the `walkdir` crate

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?

--version

Please provide --version option to print the version.

$ fd --version
1.1.0

Panic on broken pipe

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.

Apply colour to text that matched regexp

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.

Test shell script doesn't work in macOS

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

Make it fast

> 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

Compile fails

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

What I did

Attempted to install

cargo install --git https://github.com/sharkdp/fd --verbose 

What I expected to happen

That fd would be installed to my path without a fuss, much like I experienced on my Mac

What actually happened

  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! 👍

Slow inside VirtualBox shared folder

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.

flag to force color

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

Bug parsing .gitignore

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!

Show/search hidden files by default (or not)?

Possible options are [updated on 2017-06-05]:

  • Add a convenient short option for --hidden (-h is for --help ...)

=> Done already, -H can be used (alongside --hidden) for searching hidden directories.

  • Add a config file (~/.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").

  • Add a status line below the search results to indicate that files were found in hidden/ignored directories (suggestion by @chrivers below).

Properly handle invalid UTF-8 in filenames

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.