diff --git a/data/scripts/o b/data/scripts/o index fc54d15..96756fe 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -171,16 +171,18 @@ cmd_prompt() { echo "Slash commands: /stop /compact /kill /clear /model /backend /cwd /help" echo "" - local buf="" + local buf="" line while true; do + local prompt_str if [[ -z "$buf" ]]; then - printf "\033[1m>\033[0m " + prompt_str=$'\033[1m>\033[0m ' else - printf " " + prompt_str=" " fi - if ! IFS= read -r line; then + if ! IFS= read -e -r -p "$prompt_str" line; then # EOF — send remaining buffer if any if [[ -n "$buf" ]]; then + history -s "$buf" printf '%s\n' "$buf" | ollie-9p write "$path/prompt" fi printf "\n" @@ -188,6 +190,7 @@ cmd_prompt() { fi # Slash commands (only when buffer is empty — first line) if [[ -z "$buf" && "$line" == /* ]]; then + history -s "$line" local cmd="${line#/}" case "$cmd" in stop) echo "stop" | ollie-9p write "$path/ctl"; echo "[stopped]" ;; @@ -212,6 +215,7 @@ cmd_prompt() { fi if [[ -z "$line" && -n "$buf" ]]; then # Blank line sends accumulated buffer + history -s "$buf" printf '%s\n' "$buf" | ollie-9p write "$path/prompt" buf="" elif [[ -z "$line" ]]; then