Skip to content

Instantly share code, notes, and snippets.

@Tedfulk
Last active February 19, 2024 18:02
Show Gist options
  • Save Tedfulk/24aab8e32e550edf32ceb68a52adf6f7 to your computer and use it in GitHub Desktop.
Save Tedfulk/24aab8e32e550edf32ceb68a52adf6f7 to your computer and use it in GitHub Desktop.

Fish function To update Ollama models For Mac

function update_ollama_models
    echo "Fetching list of Ollama models..."
    set -l jobs
    ollama list | tail -n +2 | while read -l line
        set model_name (echo $line | awk '{print $1}')
        if test -n "$model_name"
            echo "Attempting to update model: $model_name"
            ollama pull $model_name &
            set -a jobs $last_pid
            echo "Started update for model: $model_name"
        else
            echo "No model name extracted from line: $line"
        end
    end

    for job in $jobs
        wait $job
    end
    ollama list | tail -n +2 | awk -F"\t" '{printf $1 "\t" $3 "\t" $4 "\t" $5 RS}'
    echo "Ollama models update complete."
end

Fish function To update Ollama models for linux

function update_ollama_models
    echo "Updating Ollama client..."
    curl -fsSL https://ollama.com/install.sh | sh

    if not type -q ollama
        echo "Ollama command could not be found. Please check the installation."
        return 1
    end

    set -l ollama_proc (ps aux | grep '[o]llama serve')
    if test -z "$ollama_proc"
        echo "Ollama is not running. Starting Ollama serve..."
        ollama serve &
    else
        echo "Ollama serve is already running."
    end

    echo "Fetching list of Ollama models..."
    set -l jobs
    ollama list | tail -n +2 | while read -l line
        set model_name (echo $line | awk '{print $1}')
        if test -n "$model_name"
            echo "Attempting to update model: $model_name"
            ollama pull $model_name &
            set -a jobs $last_pid
            echo "Started update for model: $model_name"
        else
            echo "No model name extracted from line: $line"
        end
    end

    for job in $jobs
        wait $job
    end
    ollama list | tail -n +2 | awk -F"\t" '{printf $1 "\t" $3 "\t" $4 "\t" $5 RS}'
    echo "Ollama models update complete."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment