@@ -153,8 +153,8 @@ build_chat_context() {
153153 fi
154154}
155155
156- escape (){
157- echo " $1 " | jq -Rrs ' tojson[1:-1]'
156+ escape () {
157+ echo " $1 " | jq -Rrs ' tojson[1:-1]'
158158}
159159
160160# maintain chat context function for /completions (all models except
@@ -290,7 +290,7 @@ MULTI_LINE_PROMPT=${MULTI_LINE_PROMPT:-false}
290290
291291# create our temp file for multi-line input
292292if [ $MULTI_LINE_PROMPT = true ]; then
293- USER_INPUT =$( mktemp)
293+ USER_INPUT_TEMP_FILE =$( mktemp)
294294 trap ' rm -f ${USER_INPUT}' EXIT
295295fi
296296
@@ -319,8 +319,9 @@ while $running; do
319319 if [ -z " $pipe_mode_prompt " ]; then
320320 if [ $MULTI_LINE_PROMPT = true ]; then
321321 echo -e " \nEnter a prompt: (Press Enter then Ctrl-D to send)"
322- cat > " ${USER_INPUT} "
323- prompt=$( sed -E ' :a;N;$!ba;s/\r{0,1}\n/\\n/g' " ${USER_INPUT} " )
322+ cat > " ${USER_INPUT_TEMP_FILE} "
323+ input_from_temp_file=$( cat " ${USER_INPUT_TEMP_FILE} " )
324+ prompt=$( escape " $input_from_temp_file " )
324325 else
325326 echo -e " \nEnter a prompt:"
326327 read -e prompt
@@ -417,7 +418,6 @@ while $running; do
417418 if command -v glow & > /dev/null; then
418419 echo -e " ${CHATGPT_CYAN_LABEL} "
419420 echo " ${response_data} " | glow -
420- # echo -e "${formatted_text}"
421421 else
422422 echo -e " ${CHATGPT_CYAN_LABEL}${response_data} " | fold -s -w " $COLUMNS "
423423 fi
0 commit comments