Search code examples
bashaliasxargs

Xargs: Alias substitution fails despite expanding the alias


I have the following command:

fd --type f -0 --full-path $HOME/something/something_inside_something | fzf --read0 --print0 --exit-0 --preview 'bat {1}' | xargs -r -0 vim

Where vim is an alias of:

NVIM_APPNAME=mynvim nvim

The command fails at the alias. I know it is correct apart from the alias, because when run without it (e.g xargs -r -0 nvim where nvim is not an alias,) it works fine.

I have tried both alias xargs='xargs ' and xargs -r -0 bash -ic vim

I have also tried a multitude of other proposed workarounds I have found on the topic in similar questions here and on the internet at large.

Anyone got any tips?

Ps: Apropos of nothing, anyone have any idea why --preview 'bat {1}' will fail to display (some) files it would normally display without a hitch?


Solution

  • Try this :

    xargs -r -0 bash -ic 'vim "$1"' _