2026-07-07 05:00:27Ollama model list with context sizes in Fish
Ollama doesn't list its models with context size, and I wanted to be able to see this info (and model size) all in one go. Fish shell is elegant for tasks like this.
( sh ) ✂
#!/usr/bin/env fish
echo
echo "Model Name Context Size"
echo
for model in (ollama list | sort | egrep -v NAME)
string replace -ra "\s+" ' ' $model | read -l name x size magnitude x x x
set length (ollama show $name | awk '/context length/ { print $3 }')
printf "%-26s %7.0f %5.1f %2s\n" $name $length $size $magnitude
end
echo
1#!/usr/bin/env fish 2 3echo 4echo "Model Name Context Size" 5echo 6 7formodel in (ollama list | sort |egrep-v NAME) 8 string replace -ra "\s+" ' '$model| read -l name x size magnitude x x x 9 set length (ollama show $name|awk'/context length/ { print $3 }') 10 11 printf "%-26s %7.0f %5.1f %2s\n" $name$length$size$magnitude 12 end 13 14echo
Curiously, and perhaps but a tiny speed bump on the road to the future, ChatGPT, Claude, and my local models, all failed hard, even after many attempts, to know how to properly do line 8, where it takes the $model line and directly assigns its parts to various variable names.
To wit, the above code was completely written without any LLM help. I have yet to see a compelling case for LLM code, but perhaps some day.