We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eec4d6d commit bfb3c7dCopy full SHA for bfb3c7d
chatgpt.sh
@@ -320,6 +320,12 @@ else
320
pipe_mode_prompt+=$(cat -)
321
fi
322
323
+function handle_ctrl_c {
324
+ # newline
325
+ echo ""
326
+}
327
+trap handle_ctrl_c INT
328
+
329
while $running; do
330
331
if [ -z "$pipe_mode_prompt" ]; then
@@ -330,7 +336,17 @@ while $running; do
336
prompt=$(escape "$input_from_temp_file")
337
else
332
338
echo -e "\nEnter a prompt:"
333
- read -e prompt
339
+ while true; do
340
+ prompt=$(read -e prompt && echo $prompt || exit 1)
341
+ # Ctrl-D
342
+ if [[ $? == 1 ]]; then
343
+ exit
344
+ fi
345
+ # Ctrl-C
346
+ if [ -n "$prompt" ]; then
347
+ break
348
349
+ done
334
350
335
351
if [[ ! $prompt =~ ^(exit|q)$ ]]; then
352
echo -ne $PROCESSING_LABEL
0 commit comments