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

Option to output colored file name only #78

Open
nkh opened this issue Dec 14, 2023 · 7 comments
Open

Option to output colored file name only #78

nkh opened this issue Dec 14, 2023 · 7 comments

Comments

@nkh
Copy link

nkh commented Dec 14, 2023

Given "aaa/bbb/entry" return only "color + entry + color reset".

Use case:

I have "$HOME/downloads", which happens to be a link, and a lot of other files from different directories in a list and want to colorize them.

The only way to get correct colorization is to be in the right directory for each entry in the list, this means starting a process for each entry and is prohibitively expensive.

I can send the full path but then I'd have to parse the colored string.

An alternative would be to output the colored path and the colored entry on different lines.

@sharkdp
Copy link
Owner

sharkdp commented Dec 16, 2023

Isn't this the same as #70?

@nkh
Copy link
Author

nkh commented Dec 16, 2023

@sharkdp

They are different.

issue 70

Add a user defined $root to every input entry

issue 78

output only the colored basename without the path

orthogonality

a list of files could be passed as arguments with --root $root to be added to the files and --name-only would only return the basename of the file colored according to the file present int $root (ie could exist and be executable in $root).

@tavianator
Copy link
Contributor

You can do this with bfs:

$ bfs -color -prune -printf '%f\n' path/to/file1 path/to/file2
file1
file2

@nkh
Copy link
Author

nkh commented Dec 16, 2023

@tavianator I would but

positive: bfs is faster than lscolors
negative: bfs doesn't accepted files on stdin which is a show stopper for me

@tavianator
Copy link
Contributor

If you can \0-separate them instead of \n, then it does support -files0-from -. If not, there's always xargs :)

@nkh
Copy link
Author

nkh commented Dec 16, 2023

@tavianator

I didn't get that far in the man page.

I'll probably end up writing a wrapper called 'lscolors' around 'bfs' till I find the time to replace it, I just found out that I use lscolors in 25 different places in my code!

@sharkdp
Copy link
Owner

sharkdp commented Jan 16, 2024

See #80 for some changes related to this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants