-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Possible to render $HOME as ~ in fd output? #1447
Comments
Judging by Ultimately I think the best solution for this is going to be #1043. |
Incidentally, and on a completely different train of thought, I stumbled upon that issue yesterday. It sounds very exciting and may indeed resolve this. But I was dismayed by how long it seemed to have languished. Hopefully the activity will pick up on that PR and it can get merged soon. Thanks! |
So #1043 has finally been merged, and while it does seem incredibly useful as is, it actually doesn't seem to allow for @sharkdp @tmccombs - Might this kind of substitution be possible/worth adding as an additional template string into |
@cohml you can now do this: tavianator@graphene $ fd --base-directory ~ --format '~/{}'
~/code
~/code/sharkdp
~/code/sharkdp/fd
~/code/sharkdp/fd/README.md
~/code/sharkdp/fd/Cross.toml
~/code/sharkdp/fd/Cargo.toml
~/code/sharkdp/fd/Cargo.lock
~/code/sharkdp/fd/CHANGELOG.md
~/code/sharkdp/fd/scripts
~/code/sharkdp/fd/scripts/version-bump.sh
... Something more general might be useful though, it's worth making a new feature request if you have use cases that aren't covered by the existing feature. |
@tavianator That looks perfect! But how are you getting those colors? For me, |
Yes, --format disables colors currently. Possibly support could be added. I'm not sure how difficult that would be. Or exactly how that would work (do we put color on the whole line, or just the path part of it?) |
Oh those colors are just GitHub syntax highlighting for |
For |
Say my
$HOME
is/Users/LongName/
. If I runfd . ~
, all results will have/Users/LongName/
prepended. Is it possible to have this prefix rendered as~/
?Of course, I could do something like
fd . ~ | sed 's/\/Users\/LongName/~'
. But this would requirefd
to finish running before any substitution occurs, slowing things down massively. So I'm wondering if it is possible to have this substitution happen at the source.If it matters, my use case is with
fzf
, where results start being loaded as soon asfd
returns them. Hence why the slowdown of thesed
approach just described would be untenable.The text was updated successfully, but these errors were encountered: