first-avail-command
is a command wrapper designed to be put in configuration files:
- where a command is accepted
- and there are several alternatives for the same task
- but it's not known which alternative is installed
first-avail-command ALTERNATIVE1 ALTERNATIVE2 [...] -- ARGS FOR COMMAND
In a config file, it should typically be called like this:
first-avail-command ALTERNATIVE1 ALTERNATIVE2 ALTERNATIVE3 --
The external runner will pass its own args after the --
.
first-avail-command
will choose the first installed alternative and feed it the external args passed after --
.
[pager]
diff = first-avail-command delta batcat bat diff-so-fancy --
- delta
- bat (or
batcat
on some systems) - diff-so-fancy
export FZF_DEFAULT_COMMAND="first-avail-command fd 'rg --files' find --"
This sample shows in addition how to pass some arguments that are specific to an alternative: here, rg
must be passed --files
, but not other alternatives.
alias ll="first-avail-command exa ls -- -l"
This sample shows in addition how to feed some extra arguments in config, which must be allowed by all alternatives: here, both ls
and exa
will receive -l
, in addition of args passed to the ll
alias.