CONTAINS(1)
πΈ CONTAINS π (the fish-shell one, bestie)
okay so real talk β this little icon lives in the fish-shell world and she is SO underrated. let me put you on π«Ά
β¨ NAME β¨
contains β test if a word is present in a list. that's it. that's the whole job. and she ate π
π¦ SYNOPSIS π¦
contains [OPTIONS] [--] KEY [VALUES ...]
π DESCRIPTION π
so basically contains checks whether the set VALUES contains the string KEY. simple as that, no cap.
- if it does contain it β
containsexits with code0π₯ - if it doesn't β it exits with code
1π
she's just a vibe check for your lists, fr fr.
the following options are available:
-i,--indexβ prints the index (that's the number of the element in the set) of the first matching element. very "which one of u did this" energy π-h,--helpβ displays help about using this command. the classic, the icon, the moment.
β οΈ important ordering tea π΅ β options must be passed beforeKEY. every argument afterKEYgets considered a value, regardless of whether it starts with a-or not β including--itself. wild, i know. so ifKEYitself starts with a-, use a--argument to separate it from the options. don't skip this step bestie, it WILL trip you up π
see the examples below, they're literally right there β¬οΈ
π EXAMPLE π
if animals is a list of animals, the following will test if animals contains "cat":
if contains cat $animals
echo Your animal list is evil!
end
(i don't make the rules, cat lists are just evil like that π)
this code will add some directories to PATH (envvar) if they aren't yet included:
for i in ~/bin /usr/local/bin
if not contains $i $PATH
set PATH $PATH $i
end
end
no duplicates, no chaos, only organization. main character energy β¨
while this will check if function hasargs is being ran 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 as an option to itself. instead it treats it as a normal string to check. so polite of it π
contains -i foo -q -- foo
this returns 3, since all arguments after the key are considered a value. yes girl, position three, we counted π
π Copyright π
fish-shell developers π
so yeah, that's the whole page bestie πΈ go forth and check your lists β no cap, you got this. and just so you know, this was the CONTAINS(1) page from fish-shell version 4.9, dated Sep 08, 2026 β love that for us π¦β¨π
π¦ where this page comes from
- arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms