fd-find-7.4.0/.gitignore010064400017500001735000000000231353750027400132460ustar0000000000000000target/ **/*.rs.bk fd-find-7.4.0/.snapcraft.yaml010064400017500001735000000017621353750027400142140ustar0000000000000000name: fd version: git summary: "A simple, fast and user-friendly alternative to 'find'" description: | fd is a simple, fast and user-friendly alternative to find. - While it does not seek to mirror all of find's powerful functionality, it provides sensible (opinionated) defaults for 80% of the use cases. Features Convenient syntax: fd PATTERN instead of find -iname '*PATTERN*'. Colorized terminal output (similar to ls). It's fast (see benchmarks below). Smart case: the search is case-insensitive by default. It switches to case-sensitive if the pattern contains an uppercase character*. Ignores hidden directories and files, by default. Ignores patterns from your .gitignore, by default. Regular expressions. Unicode-awareness. The command name is 50% shorter* than find :-). Parallel command execution with a syntax similar to GNU Parallel. grade: stable confinement: classic parts: fd: plugin: rust source: ./ apps: fd: command: bin/fd fd-find-7.4.0/.travis.yml010064400017500001735000000107721353750027400134030ustar0000000000000000language: rust cache: cargo matrix: # allow_failures: # - rust: nightly include: # Stable channel. - os: linux rust: stable env: TARGET=x86_64-unknown-linux-gnu - os: linux rust: stable env: TARGET=x86_64-unknown-linux-musl - os: linux rust: stable env: TARGET=i686-unknown-linux-gnu - os: linux rust: stable env: TARGET=i686-unknown-linux-musl - os: osx rust: stable env: TARGET=x86_64-apple-darwin - os: linux rust: stable env: - TARGET=arm-unknown-linux-gnueabihf - CC_arm_unknown_linux_gnueabihf=/usr/bin/arm-linux-gnueabihf-gcc-4.8 - CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8 - os: linux rust: stable env: - TARGET=arm-unknown-linux-musleabihf - CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8 # Beta channel. - os: linux rust: beta env: TARGET=x86_64-unknown-linux-gnu # Disabled to reduce total CI time # - os: linux # rust: beta # env: TARGET=x86_64-unknown-linux-musl # - os: linux # rust: beta # env: TARGET=i686-unknown-linux-gnu # - os: linux # rust: beta # env: TARGET=i686-unknown-linux-musl # - os: osx # rust: beta # env: TARGET=x86_64-apple-darwin # Nightly channel. - os: linux rust: nightly env: TARGET=x86_64-unknown-linux-gnu # Disabled to reduce total CI time # - os: linux # rust: nightly # env: TARGET=x86_64-unknown-linux-musl # - os: linux # rust: nightly # env: TARGET=i686-unknown-linux-gnu # - os: linux # rust: nightly # env: TARGET=i686-unknown-linux-musl # - os: osx # rust: nightly # env: TARGET=x86_64-apple-darwin # Minimum Rust supported channel. - os: linux rust: 1.31.0 env: TARGET=x86_64-unknown-linux-gnu - os: linux rust: 1.31.0 env: TARGET=x86_64-unknown-linux-musl - os: linux rust: 1.31.0 env: TARGET=i686-unknown-linux-gnu - os: linux rust: 1.31.0 env: TARGET=i686-unknown-linux-musl - os: osx rust: 1.31.0 env: TARGET=x86_64-apple-darwin # Code formatting check - os: linux rust: nightly # skip the global install step install: - cargo install --debug --force rustfmt-nightly script: cargo fmt -- --check sudo: required before_install: - ci/before_install.bash env: global: # Default target on travis-ci. # Used as conditional check in the install stage - HOST=x86_64-unknown-linux-gnu # Used on the deployment script - PROJECT_NAME=fd install: # prevent target re-add error from rustup - if [[ $TRAVIS_OS_NAME = linux && $HOST != $TARGET ]]; then rustup target add $TARGET; fi script: - ci/script.bash before_deploy: - bash ci/before_deploy.bash deploy: provider: releases # NOTE updating the `api_key.secure` # - go to: https://github.com/settings/tokens/new # - generate new token using `public_repo` scope # - encrypt it using: `travis encrypt API_KEY_HERE` # - paste the output below api_key: secure: "RyFdh2lpDmaNhPar7ezsb18Xz+6XFM40y7cZCDRML+Sk+eYK1xtDNfEhDRJU5Qo1ReVsByds/QJTSXr2KmZPk3lXwG3SiN7UtrLUxCxFr6qrcM/iujlKTf5UxeRklkzPXxnH95DEyEgxvgbVhWTGVDWoyMnrVQXZKDy6z1iAiYB5h2Zl1rs+MRb/Enlt5q6XIKAlG0ppGtl8CfYudq5ZiqfJaMWTt9SWm2YskC8FeMc0S3IM6/EhTvaNYLdaarFqVWQEVql+6oCuL3ayPzmGyxLdxM37tIMNQ0f97zxqWodacXTG5ULdRD8if1l/SmTujrtjbZ0KWRjsjOq4vBtxBJKGdprcSiB0xH/hToqqtTSO0z5FPXi5cB8UlK6YLDDHcP3kXNer8CYMLI1VPaUDLTF57/0/RPi2DZiiGfZsIAS6PsICbHdTQVzxQckM4lN1vnAGgkhXIMbztml21pv+QrGy98OZJ0ubf5ztgQhpT0WPH4JXT8M6htsoo8dZf8lQ5aLfmW9RKePJDqixQwPqmimPIkrlxRDTDGII0ZAZws7l779eOLmEcM2tH2HbsUKUCZIG/pRHLSlP45Jn2bULGzuXZ2daq70z6zvIbom0CUzSXIvdTXEZI2AM5RBvPYGGaKI8YlxgRdQvJp3h0BzPdFOXI3RAxscCY7PJpa/RdIg=" # for uploading multiple files file_glob: true # NOTE explanation on each env variable # - PROJECT_NAME: name of the project, set on the `env.global` above # - TRAVIS_TAG: tag name that the build is being deployed for, usually the version number # - TARGET: target triple of the build file: - $PROJECT_NAME-$TRAVIS_TAG-$TARGET.* - $PROJECT_NAME*.deb # don't delete artifacts from previous stage skip_cleanup: true on: # deploy only if we push a tag tags: true # deploy only on stable channel that has TARGET env variable sets condition: $TRAVIS_RUST_VERSION = stable && $TARGET != "" notifications: email: on_success: never fd-find-7.4.0/CONTRIBUTING.md010064400017500001735000000015601353750027400135160ustar0000000000000000## Contributing to *fd* **Thank you very much for considering to contribute to this project!** We welcome any form of contribution: * New issues (feature requests, bug reports, questions, ideas, ...) * Pull requests (documentation improvements, code improvements, new features, ...) **Note**: Before you take the time to open a pull request, please open a ticket first. This will give us the chance to discuss any potential changes first. ## Important links * [Open issues](https://github.com/sharkdp/fd/issues) * [Open pull requests](https://github.com/sharkdp/fd/pulls) * [Development section in the README](https://github.com/sharkdp/fd#development) * [fd on crates.io](https://crates.io/crates/fd-find) * [LICENSE-APACHE](https://github.com/sharkdp/fd/blob/master/LICENSE-APACHE) and [LICENSE-MIT](https://github.com/sharkdp/fd/blob/master/LICENSE-MIT) fd-find-7.4.0/Cargo.toml.orig010064400017500001735000000023701353750027400141540ustar0000000000000000[package] authors = ["David Peter "] build = "build.rs" categories = ["command-line-utilities"] description = "fd is a simple, fast and user-friendly alternative to find." exclude = ["/benchmarks/*"] homepage = "https://github.com/sharkdp/fd" keywords = [ "search", "find", "file", "filesystem", "tool", ] license = "MIT/Apache-2.0" name = "fd-find" readme = "README.md" repository = "https://github.com/sharkdp/fd" version = "7.4.0" edition= "2018" [[bin]] name = "fd" path = "src/main.rs" [badges.appveyor] repository = "sharkdp/fd" [badges.travis-ci] repository = "sharkdp/fd" [build-dependencies] clap = "2.31.2" version_check = "0.9" [dependencies] ansi_term = "0.12" atty = "0.2" ignore = "0.4.3" lazy_static = "1.1.0" num_cpus = "1.8" regex = "1.0.0" regex-syntax = "0.6" ctrlc = "3.1" humantime = "1.1.1" lscolors = "0.6" globset = "0.4" [dependencies.clap] version = "2.31.2" features = ["suggestions", "color", "wrap_help"] [target.'cfg(all(unix, not(target_os = "redox")))'.dependencies] libc = "0.2" [target.'cfg(all(not(windows), not(target_env = "musl")))'.dependencies] jemallocator = "0.3.0" [dev-dependencies] diff = "0.1" tempdir = "0.3" filetime = "0.2.1" [profile.release] lto = true codegen-units = 1 fd-find-7.4.0/Cargo.toml0000644000000041330000000000000104110ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "fd-find" version = "7.4.0" authors = ["David Peter "] build = "build.rs" exclude = ["/benchmarks/*"] description = "fd is a simple, fast and user-friendly alternative to find." homepage = "https://github.com/sharkdp/fd" readme = "README.md" keywords = ["search", "find", "file", "filesystem", "tool"] categories = ["command-line-utilities"] license = "MIT/Apache-2.0" repository = "https://github.com/sharkdp/fd" [profile.release] lto = true codegen-units = 1 [[bin]] name = "fd" path = "src/main.rs" [dependencies.ansi_term] version = "0.12" [dependencies.atty] version = "0.2" [dependencies.clap] version = "2.31.2" features = ["suggestions", "color", "wrap_help"] [dependencies.ctrlc] version = "3.1" [dependencies.globset] version = "0.4" [dependencies.humantime] version = "1.1.1" [dependencies.ignore] version = "0.4.3" [dependencies.lazy_static] version = "1.1.0" [dependencies.lscolors] version = "0.6" [dependencies.num_cpus] version = "1.8" [dependencies.regex] version = "1.0.0" [dependencies.regex-syntax] version = "0.6" [dev-dependencies.diff] version = "0.1" [dev-dependencies.filetime] version = "0.2.1" [dev-dependencies.tempdir] version = "0.3" [build-dependencies.clap] version = "2.31.2" [build-dependencies.version_check] version = "0.9" [target."cfg(all(not(windows), not(target_env = \"musl\")))".dependencies.jemallocator] version = "0.3.0" [target."cfg(all(unix, not(target_os = \"redox\")))".dependencies.libc] version = "0.2" [badges.appveyor] repository = "sharkdp/fd" [badges.travis-ci] repository = "sharkdp/fd" fd-find-7.4.0/LICENSE-APACHE010064400017500001735000000251211353750027400132100ustar0000000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2017 fd developers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. fd-find-7.4.0/LICENSE-MIT010064400017500001735000000017771353750027400127330ustar0000000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fd-find-7.4.0/README.md010064400017500001735000000444521353750027400125530ustar0000000000000000# fd [![Build Status](https://travis-ci.org/sharkdp/fd.svg?branch=master)](https://travis-ci.org/sharkdp/fd) [![Build status](https://ci.appveyor.com/api/projects/status/21c4p5fwggc5gy3j?svg=true)](https://ci.appveyor.com/project/sharkdp/fd) [![Version info](https://img.shields.io/crates/v/fd-find.svg)](https://crates.io/crates/fd-find) [中文](https://github.com/chinanf-boy/fd-zh) *fd* is a simple, fast and user-friendly alternative to [*find*](https://www.gnu.org/software/findutils/). While it does not seek to mirror all of *find*'s powerful functionality, it provides sensible (opinionated) defaults for [80%](https://en.wikipedia.org/wiki/Pareto_principle) of the use cases. ## Features * Convenient syntax: `fd PATTERN` instead of `find -iname '*PATTERN*'`. * Colorized terminal output (similar to *ls*). * It's *fast* (see [benchmarks](#benchmark) below). * Smart case: the search is case-insensitive by default. It switches to case-sensitive if the pattern contains an uppercase character[\*](http://vimdoc.sourceforge.net/htmldoc/options.html#'smartcase'). * Ignores hidden directories and files, by default. * Ignores patterns from your `.gitignore`, by default. * Regular expressions. * Unicode-awareness. * The command name is *50%* shorter[\*](https://github.com/ggreer/the_silver_searcher) than `find` :-). * Parallel command execution with a syntax similar to GNU Parallel. ## Demo ![Demo](doc/screencast.svg) ## Benchmark Let's search my home folder for files that end in `[0-9].jpg`. It contains ~190.000 subdirectories and about a million files. For averaging and statistical analysis, I'm using [hyperfine](https://github.com/sharkdp/hyperfine). The following benchmarks are performed with a "warm"/pre-filled disk-cache (results for a "cold" disk-cache show the same trends). Let's start with `find`: ``` Benchmark #1: find ~ -iregex '.*[0-9]\.jpg$' Time (mean ± σ): 7.236 s ± 0.090 s Range (min … max): 7.133 s … 7.385 s ``` `find` is much faster if it does not need to perform a regular-expression search: ``` Benchmark #2: find ~ -iname '*[0-9].jpg' Time (mean ± σ): 3.914 s ± 0.027 s Range (min … max): 3.876 s … 3.964 s ``` Now let's try the same for `fd`. Note that `fd` *always* performs a regular expression search. The options `--hidden` and `--no-ignore` are needed for a fair comparison, otherwise `fd` does not have to traverse hidden folders and ignored paths (see below): ``` Benchmark #3: fd -HI '.*[0-9]\.jpg$' ~ Time (mean ± σ): 811.6 ms ± 26.9 ms Range (min … max): 786.0 ms … 870.7 ms ``` For this particular example, `fd` is approximately nine times faster than `find -iregex` and about five times faster than `find -iname`. By the way, both tools found the exact same 20880 files :smile:. Finally, let's run `fd` without `--hidden` and `--no-ignore` (this can lead to different search results, of course). If *fd* does not have to traverse the hidden and git-ignored folders, it is almost an order of magnitude faster: ``` Benchmark #4: fd '[0-9]\.jpg$' ~ Time (mean ± σ): 123.7 ms ± 6.0 ms Range (min … max): 118.8 ms … 140.0 ms ``` **Note**: This is *one particular* benchmark on *one particular* machine. While I have performed quite a lot of different tests (and found consistent results), things might be different for you! I encourage everyone to try it out on their own. See [this repository](https://github.com/sharkdp/fd-benchmarks) for all necessary scripts. Concerning *fd*'s speed, the main credit goes to the `regex` and `ignore` crates that are also used in [ripgrep](https://github.com/BurntSushi/ripgrep) (check it out!). ## Colorized output `fd` can colorize files by extension, just like `ls`. In order for this to work, the environment variable [`LS_COLORS`](https://linux.die.net/man/5/dir_colors) has to be set. Typically, the value of this variable is set by the `dircolors` command which provides a convenient configuration format to define colors for different file formats. On most distributions, `LS_COLORS` should be set already. If you are looking for alternative, more complete (and more colorful) variants, see [here](https://github.com/seebi/dircolors-solarized) or [here](https://github.com/trapd00r/LS_COLORS). ## Parallel command execution If the `-x`/`--exec` option is specified alongside a command template, a job pool will be created for executing commands in parallel for each discovered path as the input. The syntax for generating commands is similar to that of GNU Parallel: - `{}`: A placeholder token that will be replaced with the path of the search result (`documents/images/party.jpg`). - `{.}`: Like `{}`, but without the file extension (`documents/images/party`). - `{/}`: A placeholder that will be replaced by the basename of the search result (`party.jpg`). - `{//}`: Uses the parent of the discovered path (`documents/images`). - `{/.}`: Uses the basename, with the extension removed (`party`). ``` bash # Convert all jpg files to png files: fd -e jpg -x convert {} {.}.png # Unpack all zip files (if no placeholder is given, the path is appended): fd -e zip -x unzip # Convert all flac files into opus files: fd -e flac -x ffmpeg -i {} -c:a libopus {.}.opus # Count the number of lines in Rust files (the command template can be terminated with ';'): fd -x wc -l \; -e rs ``` The number of threads used for command execution can be set with the `--threads`/`-j` option. ## Installation ### On Ubuntu *... and other Debian-based Linux distributions.* If you run Ubuntu 19.04 (Disco Dingo) or newer, you can install the [officially maintained package](https://packages.ubuntu.com/disco/fd-find): ``` sudo apt install fd-find ``` Note that the binary is called `fdfind` as the binary name `fd` is already used by another package. It is recommended that you add an `alias fd=fdfind` to your shells initialization file, in order to use `fd` in the same way as in this documentation. If you use an older version of Ubuntu, you can download the latest `.deb` package from the [release page](https://github.com/sharkdp/fd/releases) and install it via: ``` bash sudo dpkg -i fd_7.4.0_amd64.deb # adapt version number and architecture ``` ### On Debian If you run Debian Buster or newer, you can install the [officially maintained Debian package](https://tracker.debian.org/pkg/rust-fd-find): ``` sudo apt-get install fd-find ``` Note that the binary is called `fdfind` as the binary name `fd` is already used by another package. It is recommended that you add an `alias fd=fdfind` to your shells initialization file, in order to use `fd` in the same way as in this documentation. ### On Fedora Starting with Fedora 28, you can install `fd` from the official package sources: ``` bash dnf install fd-find ``` For older versions, you can use this [Fedora copr](https://copr.fedorainfracloud.org/coprs/keefle/fd/) to install `fd`: ``` bash dnf copr enable keefle/fd dnf install fd ``` ### On Alpine Linux You can install [the fd package](https://pkgs.alpinelinux.org/packages?name=fd) from the official sources, provided you have the appropriate repository enabled: ``` apk add fd ``` ### On Arch Linux You can install [the fd package](https://www.archlinux.org/packages/community/x86_64/fd/) from the official repos: ``` pacman -S fd ``` ### On Gentoo Linux You can use [the fd ebuild](https://packages.gentoo.org/packages/sys-apps/fd) from the official repo: ``` emerge -av fd ``` ### On openSUSE Linux You can install [the fd package](https://software.opensuse.org/package/fd) from the official repo: ``` zypper in fd ``` ### On Void Linux You can install `fd` via xbps-install: ``` xbps-install -S fd ``` ### On macOS You can install `fd` with [Homebrew](http://braumeister.org/formula/fd): ``` brew install fd ``` … or with MacPorts: ``` sudo port install fd ``` ### On Windows You can download pre-built binaries from the [release page](https://github.com/sharkdp/fd/releases). Alternatively, you can install `fd` via [Scoop](http://scoop.sh): ``` scoop install fd ``` Or via [Chocolatey](https://chocolatey.org): ``` choco install fd ``` ### On NixOS / via Nix You can use the [Nix package manager](https://nixos.org/nix/) to install `fd`: ``` nix-env -i fd ``` ### On FreeBSD You can install [the fd-find package](https://www.freshports.org/sysutils/fd) from the official repo: ``` pkg install fd-find ``` ### On OpenBSD You can install the [fd-find](https://gitlab.com/epbsd/ports/tree/master/sysutils/fd) package from the [EPBSD](https://epbsd.org/) repo: ``` ftp -o /etc/signify/epbsd-pkg.pub https://epbsd.org/epbsd-pkg.pub export PKG_PATH=https://repo.epbsd.org/pub/OpenBSD/$(arch -s):${PKG_PATH} pkg_add fd ``` ### From NPM On linux and macOS, you can install the [fd-find](https://npm.im/fd-find) package: ``` npm install -g fd-find ``` ### From source With Rust's package manager [cargo](https://github.com/rust-lang/cargo), you can install *fd* via: ``` cargo install fd-find ``` Note that rust version *1.31.0* or later is required. ### From binaries The [release page](https://github.com/sharkdp/fd/releases) includes precompiled binaries for Linux, macOS and Windows. ## Development ```bash git clone https://github.com/sharkdp/fd # Build cd fd cargo build # Run unit tests and integration tests cargo test # Install cargo install ``` ## Command-line options ``` USAGE: fd [FLAGS/OPTIONS] [] [...] FLAGS: -H, --hidden Search hidden files and directories -I, --no-ignore Do not respect .(git|fd)ignore files --no-ignore-vcs Do not respect .gitignore files -s, --case-sensitive Case-sensitive search (default: smart case) -i, --ignore-case Case-insensitive search (default: smart case) -g, --glob Glob-based search (default: regular expression) -F, --fixed-strings Treat the pattern as a literal string -a, --absolute-path Show absolute instead of relative paths -L, --follow Follow symbolic links -p, --full-path Search full path (default: file-/dirname only) -0, --print0 Separate results by the null character -h, --help Prints help information -V, --version Prints version information OPTIONS: -d, --max-depth Set maximum search depth (default: none) -t, --type ... Filter by type: file (f), directory (d), symlink (l), executable (x), empty (e) -e, --extension ... Filter by file extension -x, --exec Execute a command for each search result -X, --exec-batch Execute a command with all search results at once -E, --exclude ... Exclude entries that match the given glob pattern -c, --color When to use colors: never, *auto*, always -S, --size ... Limit results based on the size of files. --changed-within Filter by file modification time (newer than) --changed-before Filter by file modification time (older than) ARGS: the search pattern: a regular expression unless '--glob' is used (optional) ... the root directory for the filesystem search (optional) ``` This is the output of `fd -h`. To see the full set of command-line options, use `fd --help` which also includes a much more detailed help text. ## Tutorial First, to get an overview of all available command line options, you can either run `fd -h` for a concise help message (see above) or `fd --help` for a more detailed version. ### Simple search *fd* is designed to find entries in your filesystem. The most basic search you can perform is to run *fd* with a single argument: the search pattern. For example, assume that you want to find an old script of yours (the name included `netflix`): ``` bash > fd netfl Software/python/imdb-ratings/netflix-details.py ``` If called with just a single argument like this, *fd* searches the current directory recursively for any entries that *contain* the pattern `netfl`. ### Regular expression search The search pattern is treated as a regular expression. Here, we search for entries that start with `x` and end with `rc`: ``` bash > cd /etc > fd '^x.*rc$' X11/xinit/xinitrc X11/xinit/xserverrc ``` ### Specifying the root directory If we want to search a specific directory, it can be given as a second argument to *fd*: ``` bash > fd passwd /etc /etc/default/passwd /etc/pam.d/passwd /etc/passwd ``` ### Running *fd* without any arguments *fd* can be called with no arguments. This is very useful to get a quick overview of all entries in the current directory, recursively (similar to `ls -R`): ``` bash > cd fd/tests > fd testenv testenv/mod.rs tests.rs ``` If you want to use this functionality to list all files in a given directory, you have to use a catch-all pattern such as `.` or `^`: ``` bash > fd . fd/tests/ testenv testenv/mod.rs tests.rs ``` ### Searching for a particular file extension Often, we are interested in all files of a particular type. This can be done with the `-e` (or `--extension`) option. Here, we search for all Markdown files in the fd repository: ``` bash > cd fd > fd -e md CONTRIBUTING.md README.md ``` The `-e` option can be used in combination with a search pattern: ``` bash > fd -e rs mod src/fshelper/mod.rs src/lscolors/mod.rs tests/testenv/mod.rs ``` ### Hidden and ignored files By default, *fd* does not search hidden directories and does not show hidden files in the search results. To disable this behavior, we can use the `-H` (or `--hidden`) option: ``` bash > fd pre-commit > fd -H pre-commit .git/hooks/pre-commit.sample ``` If we work in a directory that is a Git repository (or includes Git repositories), *fd* does not search folders (and does not show files) that match one of the `.gitignore` patterns. To disable this behavior, we can use the `-I` (or `--no-ignore`) option: ``` bash > fd num_cpu > fd -I num_cpu target/debug/deps/libnum_cpus-f5ce7ef99006aa05.rlib ``` To really search *all* files and directories, simply combine the hidden and ignore features to show everything (`-HI`). ### Excluding specific files or directories Sometimes we want to ignore search results from a specific subdirectory. For example, we might want to search all hidden files and directories (`-H`) but exclude all matches from `.git` directories. We can use the `-E` (or `--exclude`) option for this. It takes an arbitrary glob pattern as an argument: ``` bash > fd -H -E .git … ``` We can also use this to skip mounted directories: ``` bash > fd -E /mnt/external-drive … ``` .. or to skip certain file types: ``` bash > fd -E '*.bak' … ``` To make exclude-patterns like these permanent, you can create a `.fdignore` file. They work like `.gitignore` files, but are specific to `fd`. For example: ``` bash > cat ~/.fdignore /mnt/external-drive *.bak ``` Note: `fd` also supports `.ignore` files that are used by other programs such as `rg` or `ag`. ### Using fd with `xargs` or `parallel` If we want to run a command on all search results, we can pipe the output to `xargs`: ``` bash > fd -0 -e rs | xargs -0 wc -l ``` Here, the `-0` option tells *fd* to separate search results by the NULL character (instead of newlines). In the same way, the `-0` option of `xargs` tells it to read the input in this way. ### Deleting files You can use `fd` to remove all files and directories that are matched by your search pattern. If you only want to remove files, you can use the `--exec-batch`/`-X` option to call `rm`. For example, to recursively remove all `.DS_Store` files, run: ``` bash > fd -H '^\.DS_Store$' -tf -X rm ``` If you are unsure, always call `fd` without `-X rm` first. Alternatively, use `rm`s "interactive" option: ``` bash > fd -H '^\.DS_Store$' -tf -X rm -i ``` If you also want to remove a certain class of directories, you can use the same technique. You will have to use `rm`s `--recursive`/`-r` flag to remove directories. Note: there are scenarios where using `fd … -X rm -r` can cause race conditions: if you have a path like `…/foo/bar/foo/…` and want to remove all directories named `foo`, you can end up in a situation where the outer `foo` directory is removed first, leading to (harmless) *"'foo/bar/foo': No such file or directory"* errors in the `rm` call. ### Troubleshooting #### `fd` does not find my file! Remember that `fd` ignores hidden directories and files by default. It also ignores patterns from `.gitignore` files. If you want to make sure to find absolutely every possible file, always use the options `-H` and `-I` to disable these two features: ``` bash > fd -HI … ``` #### `fd` doesn't seem to interpret my regex pattern correctly A lot of special regex characters (like `[]`, `^`, `$`, ..) are also special characters in your shell. If in doubt, always make sure to put single quotes around the regex pattern: ``` bash > fd '^[A-Z][0-9]+$' ``` If your pattern starts with a dash, you have to add `--` to signal the end of command line options. Otherwise, the pattern will be interpreted as a command-line option. Alternatively, use a character class with a single hyphen character: ``` bash > fd -- '-pattern' > fd '[-]pattern' ``` ### Integration with other programs #### Using fd with `fzf` You can use *fd* to generate input for the command-line fuzzy finder [fzf](https://github.com/junegunn/fzf): ``` bash export FZF_DEFAULT_COMMAND='fd --type file' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" ``` Then, you can type `vim ` on your terminal to open fzf and search through the fd-results. Alternatively, you might like to follow symbolic links and include hidden files (but exclude `.git` folders): ``` bash export FZF_DEFAULT_COMMAND='fd --type file --follow --hidden --exclude .git' ``` You can even use fd's colored output inside fzf by setting: ``` bash export FZF_DEFAULT_COMMAND="fd --type file --color=always" export FZF_DEFAULT_OPTS="--ansi" ``` For more details, see the [Tips section](https://github.com/junegunn/fzf#tips) of the fzf README. #### Using fd with `emacs` The emacs package [find-file-in-project](https://github.com/technomancy/find-file-in-project) can use *fd* to find files. After installing `find-file-in-project`, add the line `(setq ffip-use-rust-fd t)` to your `~/.emacs` or `~/.emacs.d/init.el` file. In emacs, run `M-x find-file-in-project-by-selected` to find matching files. Alternatively, run `M-x find-file-in-project` to list all available files in the project. fd-find-7.4.0/appveyor.yml010064400017500001735000000057651353750027400136700ustar0000000000000000# Source: https://github.com/starkat99/appveyor-rust/ environment: global: PROJECT_NAME: fd matrix: # Stable channel - TARGET: i686-pc-windows-gnu CHANNEL: stable - TARGET: i686-pc-windows-msvc CHANNEL: stable - TARGET: x86_64-pc-windows-gnu CHANNEL: stable - TARGET: x86_64-pc-windows-msvc CHANNEL: stable # Beta channel (disabled for speed reasons) #- TARGET: i686-pc-windows-gnu # CHANNEL: beta #- TARGET: i686-pc-windows-msvc # CHANNEL: beta #- TARGET: x86_64-pc-windows-gnu # CHANNEL: beta #- TARGET: x86_64-pc-windows-msvc # CHANNEL: beta # Nightly channel (disabled for speed reasons) #- TARGET: i686-pc-windows-gnu # CHANNEL: nightly #- TARGET: i686-pc-windows-msvc # CHANNEL: nightly #- TARGET: x86_64-pc-windows-gnu # CHANNEL: nightly #- TARGET: x86_64-pc-windows-msvc # CHANNEL: nightly # Install Rust and Cargo # (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml) install: - curl -sSf -o rustup-init.exe https://win.rustup.rs - rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - rustc -Vv - cargo -V # 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents # the "directory does not contain a project or solution file" error. # source: https://github.com/starkat99/appveyor-rust/blob/master/appveyor.yml#L113 build: false # Equivalent to Travis' `script` phase test_script: - cargo build --verbose - cargo run - cargo test before_deploy: # Generate artifacts for release - cargo build --release - mkdir staging - copy target\release\fd.exe staging - ps: copy target\release\build\fd-find*\out\_fd.ps1 staging - cd staging # release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc' - 7z a ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip * - appveyor PushArtifact ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip deploy: description: 'Windows release' # All the zipped artifacts will be deployed artifact: /.*\.zip/ # Here's how: # - Go to 'https://github.com/settings/tokens/new' and generate a Token with only the # `public_repo` scope enabled # - Then go to 'https://ci.appveyor.com/tools/encrypt' and enter the newly generated token. # - Enter the "encrypted value" below auth_token: secure: mWJ8ieZdGEgHf232fdMyzb9T1rKbkJivYbp/REMo8ax3X5vkQJDHhFjWeuWA3wIC provider: GitHub # deploy when a new tag is pushed and only on the stable channel on: # channel to use to produce the release artifacts CHANNEL: stable appveyor_repo_tag: true branches: only: - master # IMPORTANT Regex to match tags. Required, or appveyor may not trigger deploys when a new tag # is pushed. This regex matches semantic versions like v1.2.3-rc4+2016.02.22 - /^v\d+\.\d+\.\d+.*$/ # Disable caching, for now #cache: # - '%USERPROFILE%\.cargo' # - 'target -> Cargo.lock' fd-find-7.4.0/build.rs010064400017500001735000000023251353750027400127320ustar0000000000000000// Copyright (c) 2017 fd developers // Licensed under the Apache License, Version 2.0 // // or the MIT license , // at your option. All files in the project carrying such // notice may not be copied, modified, or distributed except // according to those terms. use clap::Shell; use std::fs; use std::io::{self, Write}; use std::process::exit; include!("src/app.rs"); fn main() { match version_check::is_min_version("1.31") { Some(true) => {} // rustc version too small or can't figure it out _ => { writeln!(&mut io::stderr(), "'fd' requires rustc >= 1.31").unwrap(); exit(1); } } let var = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR")); let outdir = match var { None => return, Some(outdir) => outdir, }; fs::create_dir_all(&outdir).unwrap(); let mut app = build_app(); app.gen_completions("fd", Shell::Bash, &outdir); app.gen_completions("fd", Shell::Fish, &outdir); app.gen_completions("fd", Shell::Zsh, &outdir); app.gen_completions("fd", Shell::PowerShell, &outdir); } fd-find-7.4.0/ci/.gitattributes010064400017500001735000000000241353750027400145450ustar0000000000000000* linguist-vendored fd-find-7.4.0/ci/before_deploy.bash010075500017500001735000000131151353750027400153370ustar0000000000000000#!/usr/bin/env bash # Building and packaging for release set -ex build() { cargo build --target "$TARGET" --release --verbose } pack() { local tempdir local out_dir local package_name local gcc_prefix tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) out_dir=$(pwd) package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET" if [[ $TARGET == arm-unknown-linux-* ]]; then gcc_prefix="arm-linux-gnueabihf-" else gcc_prefix="" fi # create a "staging" directory mkdir "$tempdir/$package_name" mkdir "$tempdir/$package_name/autocomplete" # copying the main binary cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/" "${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME" # manpage, readme and license cp "doc/$PROJECT_NAME.1" "$tempdir/$package_name" cp README.md "$tempdir/$package_name" cp LICENSE-MIT "$tempdir/$package_name" cp LICENSE-APACHE "$tempdir/$package_name" # various autocomplete cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion" cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete" cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete" # archiving pushd "$tempdir" tar czf "$out_dir/$package_name.tar.gz" "$package_name"/* popd rm -r "$tempdir" } make_deb() { local tempdir local architecture local version local dpkgname local conflictname local homepage local maintainer local gcc_prefix homepage="https://github.com/sharkdp/fd" maintainer="David Peter " case $TARGET in x86_64*) architecture=amd64 gcc_prefix="" ;; i686*) architecture=i386 gcc_prefix="" ;; arm*hf) architecture=armhf gcc_prefix="arm-linux-gnueabihf-" ;; *) echo "make_deb: skipping target '${TARGET}'" >&2 return 0 ;; esac version=${TRAVIS_TAG#v} if [[ $TARGET = *musl* ]]; then dpkgname=$PROJECT_NAME-musl conflictname=$PROJECT_NAME else dpkgname=$PROJECT_NAME conflictname=$PROJECT_NAME-musl fi tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) # copy the main binary install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME" "${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME" # manpage install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" # readme and license install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md" install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT" install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE" cat > "$tempdir/usr/share/doc/$PROJECT_NAME/copyright" < "$tempdir/DEBIAN/control" <