Skip to content
Myr

Add `-l`/`--list` option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add a new `-l`/`--list` option to show more details about the search results. This is basically an alias for `--exec-batch ls -l` with some additional `ls` options. This can be used in order to: * see metadata like permissions, owner, file size, modification times (#491) * see symlink targets (#482) * achieve a deterministic output order (#324, #196, #159) * avoid duplicate search results when multiple search paths are given (#405)

authored by sharkdp · committed by David Peter · parent 1714d41 · Browse files · 4 files+50 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+50 added−4 removed

  • other:+50 added−4 removed

4 files+50 added−4 removed

modified:doc/fd.1+6 added
64 unmodified lines
65.TP66.B \-a, \-\-absolute\-path67Shows the full path starting from the root as opposed to relative paths.68.TP69.B \-l, \-\-list70Use a detailed listing format like 'ls -l'. This is basically an alias71for '--exec-batch ls -l' with some additional 'ls' options. This can be used72to see more metadata, to show symlink targets, to achieve a deterministic73sort order and to avoid duplicate search results when using multiple search paths.74.TP75.B \-L, \-\-follow76By default, fd does not descend into symlinked directories. Using this flag, symbolic links are77also traversed.78.TP
199 unmodified lines
modified:src/app.rs+17 added-3 removed
107 unmodified lines
108 .short("a")109 .overrides_with("absolute-path"),110 )111 .arg(112 arg("list")113 .long("list")114 .short("l")115 .conflicts_with("absolute-path"),116 )117 .arg(118 arg("follow")119 .long("follow")120 .short("L")121 .alias("dereference")
8 unmodified lines
130 .arg(131 arg("null_separator")132 .long("print0")133 .short("0")128 .overrides_with("print0"),134 .overrides_with("print0")135 .conflicts_with("list"),136 )137 .arg(arg("depth").long("max-depth").short("d").takes_value(true))138 // support --maxdepth as well, for compatibility with rg139 .arg(
39 unmodified lines
179 .short("x")180 .min_values(1)181 .allow_hyphen_values(true)182 .value_terminator(";")176 .value_name("cmd"),183 .value_name("cmd")184 .conflicts_with("list"),185 )186 .arg(187 arg("exec-batch")188 .long("exec-batch")
1 unmodified line
190 .min_values(1)191 .allow_hyphen_values(true)192 .value_terminator(";")193 .value_name("cmd")186 .conflicts_with("exec"),194 .conflicts_with_all(&["exec", "list"]),195 )196 .arg(197 arg("exclude")198 .long("exclude")
151 unmodified lines
350 , "Treat the pattern as a literal string instead of a regular expression.");351 doc!(h, "absolute-path"352 , "Show absolute instead of relative paths"353 , "Shows the full path starting from the root as opposed to relative paths.");354 doc!(h, "list"355 , "Use a detailed listing format"356 , "Use a detailed listing format like 'ls -l'. This is basically an alias \357 for '--exec-batch ls -l' with some additional 'ls' options. This can be used \358 to see more metadata, to show symlink targets, to achieve a deterministic \359 sort order and to avoid duplicate search results when using multiple search paths.");360 doc!(h, "path-separator"361 , "Set the path separator to use when printing file paths."362 , "Set the path separator to use when printing file paths. The default is the OS-specific \363 separator ('/' on Unix, '\\' on Windows).");
146 unmodified lines
modified:src/main.rs+19 added
163 unmodified lines
164 CommandTemplate::new_batch(m).unwrap_or_else(|e| {165 print_error_and_exit!("{}", e);166 })167 })168 })169 .or_else(|| {170 if matches.is_present("list") {171 let color = matches.value_of("color").unwrap_or("auto");172 let color_arg = ["--color=", color].concat();173174 Some(175 CommandTemplate::new_batch(&[176 "ls",177 "-l", // long listing format178 "--human-readable", // human readable file sizes179 "--directory", // list directories themselves, not their contents180 &color_arg, // enable colorized output, if enabled181 ])182 .unwrap(),183 )184 } else {185 None186 }187 });188189 let size_limits: Vec<SizeFilter> = matches190 .values_of("size")
134 unmodified lines
modified:CHANGELOG.md+8 added-1 removed
1# Upcoming release23## Features45- Add a new `-l`/`--list` option to show more details about the search results. This is basically6 an alias for `--exec-batch ls -l` with some additional `ls` options.7 This can be used in order to:8 * see metadata like permissions, owner, file size, modification times (#491)9 * see symlink targets (#482)10 * achieve a deterministic output order (#324, #196, #159)11 * avoid duplicate search results when multiple search paths are given (#405)5- Added `--max-results=<count>` option to limit the number of search results, see #472 and #47612- Add a new `--max-results=<count>` option to limit the number of search results, see #472 and #47613 This can be useful to speed up searches in cases where you know that there are only N results.14 Using this option is also (slightly) faster than piping to `head -n <count>` where `fd` can only15 exit when it finds the search results `<count> + 1`.16- Support additional ANSI font styles in `LS_COLORS`: faint, slow blink, rapid blink, dimmed, hidden and strikethrough.
412 unmodified lines