I have ~/bin in my PATH and keep a short script with my favorite defaults available for all shells of my system (at different times I use Dash, Bash and Fish). This is tiny:
!/usr/bin/env sh exec xargs -rd\\n " $@ "
The script is called x to avoid conflicts with scripts that expect standard xargs to default. If you try to replace xargs with yourself, which I do not recommend, make sure your ~/bin displayed higher in your PATH than in the xargs system. which -a xargs tells me that the only xargs exists in /usr/bin/xargs on my system, so I know that my home directory, /home/stephen/bin , should appear before it like this:
$ echo "$PATH" /home/stephen/bin:...:/usr/bin:...
In any case, as a script available for all programs, this means that you can do things like find|x grep and sh -c 'x ...' .
If you use Bash and prefer an alias, you can also just use:
alias x=xargs -rd\\n\
Note the trailing space for the alias extension. This allows you to bind aliases. For example, if, in addition to the above alias, I had an alias for grep called g , the following:
# extended regex, skip binaries, devices, sockets, & dirs, colored, & line
The x / xargs script approach cannot do this effectively on its own.
Since I switch between shells and use one computer mostly, I save several aliases that I need as separate scripts in ~/bin and agnostic shell aliases in the script helper, ~/.sh_aliases , which is created by ~/.shrc , ~/.bashrc and ~/.config/fish/config.fish as they all support Bash syntax syntax. If I regularly worked on several PCs, I would most likely try to combine them into ~/.bashrc .