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