A smart autocompletion script for the ollama CLI in Bash.
- Dynamic Local Models: Automatically fetches your currently downloaded models for commands like
ollama run,ollama rm,ollama show,ollama cp, andollama push. - Intelligent Pull Suggestions: When typing
ollama pull, it will suggest the most popular base models (likellama3,qwen2.5,mistral, etc.) and seamlessly combine them with the base names of models you already have locally. - Colon Tag Support: Seamlessly handles tags containing colons (e.g.
llama3:8b) without breaking word splitting.
Source the script directly in your terminal:
source ./ollama-bash-completion.shTo have it load automatically every time you open a terminal:
- Copy the script to a safe location, or the default bash-completion user directory:
mkdir -p ~/.local/share/bash-completion/completions
cp ollama-bash-completion.sh ~/.local/share/bash-completion/completions/ollama- Alternatively, you can add it to your
.bashrc:
echo "source \"$(pwd)/ollama-bash-completion.sh\"" >> ~/.bashrc
source ~/.bashrcTry typing the following and hitting <TAB>:
ollama r<TAB>-> completes tormorrunollama run <TAB>-> lists your downloaded modelsollama pull l<TAB>-> lists popular models likellama3,llavaollama pull llama3:<TAB>-> fetches and suggests available tags like8b,70b,instruct, etc.