mirror of
https://github.com/0xacx/chatGPT-shell-cli.git
synced 2025-02-22 02:35:30 +00:00
Merge pull request #76 from 0xacx/wrap-output-to-term-width
Wrap output to term width
This commit is contained in:
commit
3f13f0a5b9
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user