From 1f37cbb70bb5370b4d0c63f1471540b8ac5ed5d8 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sun, 26 Oct 2025 16:45:00 +0100 Subject: [PATCH] feat(ai): implement typora flag --- ai.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/ai.sh b/ai.sh index 96bb294..4e2dd38 100755 --- a/ai.sh +++ b/ai.sh @@ -9,10 +9,32 @@ model=$helper modelfile=$helper_modelfile # Initialize variables -typora_flag=false other_args=${@:2} +typora_flag=false -# TODO: extract typora flag +# Parse options +while getopts "t" opt; do + case "$opt" in + t) + typora_flag=true # -t was given + ;; + esac +done + +# parse string args (when used as a function and passed "$@") +POSITIONAL_ARGS=() +while [[ $# -gt 0 ]]; do + case $1 in + -t) + typora_flag=true + shift # past argument + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done if ! [ "$other_args" = "" ]; then if [ "$other_args" = "open-webui" ]; then @@ -53,7 +75,7 @@ if ! [ "$other_args" = "" ]; then # If -t flag is set, use typora to display output if [ "$typora_flag" = true ]; then tempfile="$(mktemp)" - OLLAMA_HOST=$host ollama run $model "$other_args" > $tempfile + OLLAMA_HOST=$host ollama run $model "$other_args" --hidethinking > $tempfile typora $tempfile > /dev/null 2>/dev/null & else # If no -t flag, just run the command normally