Skip to content
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

Uniform output format when searching a parent directory #107

Closed
sharkdp opened this issue Oct 13, 2017 · 10 comments · Fixed by #113
Closed

Uniform output format when searching a parent directory #107

sharkdp opened this issue Oct 13, 2017 · 10 comments · Fixed by #113
Milestone

Comments

@sharkdp
Copy link
Owner

sharkdp commented Oct 13, 2017

(courtesy of @iology in #102)

Consider this directory tree:

> tree
.
├── dir1
│   ├── file1
│   └── file2
└── dir2
    ├── file3
    └── file4

2 directories, 4 files

Now, go to dir1 and perform a search in the parent directory:

> cd dir1
> fd '' ..
.
../dir2
../dir2/file3
../dir2/file4
file1
file2

The results are correct, but it would be more helpful if the output would look like this (in some order):

> cd dir1
> fd '' ..
../dir1
../dir2
../dir2/file3
../dir2/file4
../dir1/file1
../dir1/file2
@Doxterpepper
Copy link
Contributor

How about making this a flag like --tree? That would allow the tree structure when wanted but then it will default to the original output by default. It's often easier to work with the default output when scripting.

@jakwings
Copy link
Contributor

@Doxterpepper: It's often easier to work with the default output when scripting.

Examples?

@Doxterpepper
Copy link
Contributor

Normally when I'm searching for a file I am intending to do something with it such as edit it with a text editor. If the output is like the original output it is easier to copy and paste into the next command, or to include it in a script to perform some action on each file. A crude example would be:

for file in $(fd 'foo.txt' .)
do
  echo 'some change' >> $file
done  

I think the tree output is great for humans to read, perhaps the tree output could be default unless something like --plain is given. In either case the option for basic output would be good in my opinion.

@jakwings
Copy link
Contributor

@Doxterpepper I still don't see why you don't want "../dir1/file1" (instead of "file1"), while you still tolerate "../dir2/file3". And to copy/paste "file1" is just a double click.

NOTE: Your example use ".", not "..".

@Doxterpepper
Copy link
Contributor

Doxterpepper commented Oct 13, 2017

I think I misunderstood the description, I thought the suggestion was to include tree style output with ascii decorators and all. Disregard my comments above.

@Doxterpepper
Copy link
Contributor

understanding the requirements better now, would anyone oppose me taking this on?

@jakwings
Copy link
Contributor

No problem, I haven't started on this one.

@jakwings
Copy link
Contributor

jakwings commented Oct 14, 2017

Ooops, while fixing #82, I inadvertently implemented this feature. :P

@sharkdp
Copy link
Owner Author

sharkdp commented Oct 14, 2017

Ooops, while fixing #82, I inadvertently implemented this feature. :P

Sounds good 😄. Would you like to open a PR for that?

@jakwings
Copy link
Contributor

Sounds good 😄. Would you like to open a PR for that?

Some superfluous slashes and dots in the output is giving me a headache, #112 only solves part of the problem. (Linux) I need to fix that first. 🤕

sharkdp pushed a commit that referenced this issue Oct 15, 2017
@sharkdp sharkdp added this to the v5.0 milestone Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants