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

Append indicator (one of */=>@|) to entries #969

Open
mmahmoudian opened this issue Feb 28, 2022 · 2 comments
Open

Append indicator (one of */=>@|) to entries #969

mmahmoudian opened this issue Feb 28, 2022 · 2 comments

Comments

@mmahmoudian
Copy link

mmahmoudian commented Feb 28, 2022

Disclaimer: I tried to search to see if this is duplicate, but it didn't come up in any of my searches. I'm sorry if this is duplicated, but I really didn't find anything that is even remotely similar.

Feature request

Many CLI tools support a CLI flag to append certain characters to the end of each entry depending on their type. Perhaps the most common type is adding / to the end of directories to indicate that they are directories. For instance ls and tree both provide -F to append indicator (one of */=>@|) to entries. ls even provides --classify[=WHEN] which can be 'always' (default if omitted), 'auto', or 'never'.

The tree defines is as:

Append a '/' for directories, a '=' for socket files, a '*' for executable files, a '>' for doors (Solaris) and a '|' for FIFO's

In the current fd implementation, one should either do --type d to extract the folders or use --list-details to get the type and then later use cut or something to remove the extra columns. Considering that fd already knows what the item is, it would be super handy to have it append these characters.

If you wonder about my use case, one of the ways I have integrated fd into my workflow is by piping the output to fzf. I can of course ask fd to produce colors an ask fzf to handle ANSI colors, but it would be more ideal to have the characters at the end. As you can see in the following example screenshot, if the colors are not there, it is impossible to differentiate between folders and files:

image

@tavianator
Copy link
Collaborator

The trailing slash for directories is #436, with an implementation in #812.

@mmahmoudian
Copy link
Author

mmahmoudian commented Feb 28, 2022

@tavianator Thanks for pointing it out. I have clearly missed it by not searching for "slash".

I read most of the discussions in #436 and they are all tailored around having the / after folders (which is what I originally was diving into manpages to get it working), but considering that ls and tree (and most definitely many others) support this convention, I believe it is a good practice to support it as a whole rather than specifically for directories. As mentioned in that thread, it is extremely easy to strip the characters but it is a pain to add them. Additionally, the --classify[=WHEN] in ls can even get extra arguments (e.g directory, pipe or directory+pipe+link) to give the user more freedom and customizability.

@ means symbolic link (or that the file has extended attributes).
* means executable.
= means socket.
| means named pipe.
> means door.
/ means directory.

Therefore, as far as I understand, the #436 is a subset of this feature request, and #812 is partial implementation of the convention.

update: I just saw a comment on that thread that has correctly pointed out that this is the GNU formatting style.

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

No branches or pull requests

2 participants