@@ -15,6 +15,8 @@ COMMAND_GENERATION_PROMPT="Return a one-line bash command with the functionality
1515
1616CHATGPT_CYAN_LABEL=" \n\033[36mchatgpt \033[0m"
1717
18+ PROCESSING_LABEL=" \033[90mprocessing... \033[0m"
19+
1820usage () {
1921 cat << EOF
2022A simple, lightweight shell script to use OpenAI's chatGPT and DALL-E from the terminal without installing python or node.js.
@@ -272,6 +274,9 @@ while $running; do
272274 if [ -z " $pipe_mode_prompt " ]; then
273275 echo -e " \nEnter a prompt:"
274276 read -e prompt
277+ if [ " $prompt " != " exit" ] && [ " $prompt " != " q" ]; then
278+ echo -e $PROCESSING_LABEL
279+ fi
275280 else
276281 # set vars for pipe mode
277282 prompt=${pipe_mode_prompt}
@@ -328,7 +333,7 @@ while $running; do
328333 response_data=$( echo $response | jq -r ' .choices[].message.content' )
329334
330335 if [[ " $prompt " =~ ^command: ]]; then
331- echo -e " ${CHATGPT_CYAN_LABEL} ${response_data} \n "
336+ echo -e " ${CHATGPT_CYAN_LABEL} ${response_data} " | fold -s -w $COLUMNS
332337 dangerous_commands=(" rm" " >" " mv" " mkfs" " :(){:|:&};" " dd" " chmod" " wget" " curl" )
333338
334339 for dangerous_command in " ${dangerous_commands[@]} " ; do
@@ -360,7 +365,7 @@ while $running; do
360365 handle_error " $response "
361366 response_data=$( echo " $response " | jq -r ' .choices[].message.content' )
362367
363- echo -e " ${CHATGPT_CYAN_LABEL}${response_data} "
368+ echo -e " ${CHATGPT_CYAN_LABEL}${response_data} " | fold -s -w $COLUMNS
364369
365370 escaped_response_data=$( echo " $response_data " | sed ' s/"/\\"/g' )
366371 add_assistant_response_to_chat_message " $chat_message " " $escaped_response_data "
@@ -380,7 +385,7 @@ while $running; do
380385 request_to_completions " $request_prompt "
381386 handle_error " $response "
382387 response_data=$( echo " $response " | jq -r ' .choices[].text' | sed ' 1,2d; s/^A://g' )
383- echo -e " ${CHATGPT_CYAN_LABEL}${response_data} "
388+ echo -e " ${CHATGPT_CYAN_LABEL}${response_data} " | fold -s -w $COLUMNS
384389
385390 if [ " $CONTEXT " = true ]; then
386391 escaped_response_data=$( echo " $response_data " | sed ' s/"/\\"/g' )
0 commit comments