Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion chatgpt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ else
pipe_mode_prompt+=$(cat -)
fi

function handle_ctrl_c {
# newline
echo ""
}
trap handle_ctrl_c INT

while $running; do

if [ -z "$pipe_mode_prompt" ]; then
Expand All @@ -326,7 +332,17 @@ while $running; do
prompt=$(escape "$input_from_temp_file")
else
echo -e "\nEnter a prompt:"
read -e prompt
while true; do
prompt=$(read -e prompt && echo $prompt || exit 1)
# Ctrl-D
if [[ $? == 1 ]]; then
exit
fi
# Ctrl-C
if [ -n "$prompt" ]; then
break
fi
done
fi
if [[ ! $prompt =~ ^(exit|q)$ ]]; then
echo -ne $PROCESSING_LABEL
Expand Down