Fish

Loops

for file in *.txt;
    echo "$file";
end
while read word;
    echo "$word"
end < /usr/share/dict/words
while test -f foo;
    true
end

Conditions

if test $status -ne 0;
    echo "oop—"
end
  • -eq
  • -ne
  • -gt
  • -ge
  • -lt
  • -le
  • -f
  • -d
if ...;
    echo something
else if ...;
    echo something_else
else;
    echo something_else_altogether
end

Variables

set foo hi
  • -l — scoped local to the current block
  • -g — global scope
  • -x — environment variable

Command Substitution

set total (math "$total+1")