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 β†’ contains exits with code 0 πŸ”₯
  • 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 before KEY. every argument after KEY gets considered a value, regardless of whether it starts with a - or not β€” including -- itself. wild, i know. so if KEY itself 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 πŸ’…


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