fd
fd copied to clipboard
Add default flags for programs used with exec
Very very often I use fd
to grep
inside many files at once. For example:
fd . -e py -X grep foo
However, the results come back without color, which can be hard to parse. So I must always manually specify --color=always
:
fd . -e py -X grep --color=always foo
This left me wondering if it were somehow possible to, without relying on global aliases, configure things such that when I pass command X into exec
/exec-batch
, default flags appropriate for X would also be automatically supplied.
For example, perhaps some fdexec.rc
/fdx.rc
file with contents like
du="-h"
grep="--color=always --line-number"
rm="-i"
Let me know you think about this proposal, or if the desired behavior is already possible, please let me know how. Thanks!
A possible work around for this:
Create a wrapper script that looks like
com="$1"
shift
case "$com" in
du) du -h "$@";;
grep) grep --color=always --line-number "$@";;
rm) rm -i "$@"
esac
then you can use fd . -e py -X invoke grep foo
where invoke
is the name of your script.
Hey that's pretty slick, thanks @tmccombs!
Not as simple or elegant IMHO as supporting this feature natively from within fd
as I initially described. But in the meantime, your proposal is a very nice stopgap solution.