contains [OPTIONS] KEY [VALUES...]
The following options are available:
Note that, like GNU tools and most of fish's builtins, contains interprets all arguments starting with a - as options to contains, until it reaches an argument that is -- (two dashes). See the examples below.
if contains cat $animals echo Your animal list is evil! end
This code will add some directories to $PATH if they aren't yet included:
for i in ~/bin /usr/local/bin if not contains $i $PATH set PATH $PATH $i end end
While this will check if hasargs was run with the -q option:
function hasargs if contains -- -q $argv echo '$argv contains a -q option' end end
The -- here stops contains from treating -q to an option to itself. Instead it treats it as a normal string to check.