o prompt: drop readline for paste support

Switch from 'read -e' to plain 'read' so multi-line paste can be
captured. Readline was consuming pasted lines individually.
Increase drain timeout to 100ms.
This commit is contained in:
Levi Neely 2026-08-07 17:46:35 +02:00
parent 189ec65aae
commit 07ec63704e
1 changed files with 10 additions and 4 deletions

View File

@ -313,14 +313,19 @@ cmd_prompt() {
echo ""
local buf="" line
# Enable bracketed paste mode - terminal sends \e[200~ before and \e[201~ after paste
bind 'set enable-bracketed-paste on' 2>/dev/null
while true; do
local prompt_str
if [[ -z "$buf" ]]; then
prompt_str=$'\001\033[1m\002>\001\033[0m\002 '
prompt_str=$'\033[1m>\033[0m '
else
prompt_str=" "
fi
if ! IFS= read -e -r -p "$prompt_str" line; then
printf '%s' "$prompt_str"
if ! IFS= read -r line; then
if [[ -n "$buf" ]]; then
history -s "$buf"
printf '%s\n' "$buf" | ollie-9p write "$path/prompt"
@ -328,8 +333,9 @@ cmd_prompt() {
printf "\n"
break
fi
# Drain any remaining lines from a multi-line paste (bracketed paste or fast input)
while IFS= read -r -t 0.05 extra_line; do
# Drain any additional lines that arrived quickly (multi-line paste)
while IFS= read -r -t 0.1 extra_line; do
line="$line"$'\n'"$extra_line"
done
if [[ -z "$buf" && "$line" == /* ]]; then