Merge pull request #76 from 0xacx/wrap-output-to-term-width

Wrap output to term width
This commit is contained in:
0xacx 2023-04-08 13:56:22 +03:00 committed by GitHub
commit 3f13f0a5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -292,7 +292,7 @@ while $running; do
response_data=$(echo $response | jq -r '.choices[].message.content')
if [[ "$prompt" =~ ^command: ]]; then
echo -e "${CHATGPT_CYAN_LABEL} ${response_data}\n"
echo -e "${CHATGPT_CYAN_LABEL} ${response_data}" | fold -s -w $COLUMNS
dangerous_commands=("rm" ">" "mv" "mkfs" ":(){:|:&};" "dd" "chmod" "wget" "curl")
for dangerous_command in "${dangerous_commands[@]}"; do
@ -324,7 +324,7 @@ while $running; do
handle_error "$response"
response_data=$(echo "$response" | jq -r '.choices[].message.content')
echo -e "${CHATGPT_CYAN_LABEL}${response_data}"
echo -e "${CHATGPT_CYAN_LABEL}${response_data}" | fold -s -w $COLUMNS
escaped_response_data=$(echo "$response_data" | sed 's/"/\\"/g')
add_assistant_response_to_chat_message "$chat_message" "$escaped_response_data"
@ -344,7 +344,7 @@ while $running; do
request_to_completions "$request_prompt"
handle_error "$response"
response_data=$(echo "$response" | jq -r '.choices[].text' | sed '1,2d; s/^A://g')
echo -e "${CHATGPT_CYAN_LABEL}${response_data}"
echo -e "${CHATGPT_CYAN_LABEL}${response_data}" | fold -s -w $COLUMNS
if [ "$CONTEXT" = true ]; then
escaped_response_data=$(echo "$response_data" | sed 's/"/\\"/g')