From e0151744678e89a7df91e636fb347cf11c208c97 Mon Sep 17 00:00:00 2001 From: vlw Date: Mon, 6 Apr 2026 10:25:27 +0200 Subject: [PATCH] feat: print response code to CLI (#10) Closes #8 Reviewed-on: https://codeberg.org/vlw/curl/pulls/10 Co-authored-by: vlw Co-committed-by: vlw --- README.md | 2 +- curl.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f95e88..65e6e4b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![screenshot](https://codeberg.org/attachments/1cae98c6-0873-41fd-aad0-d33bf495fc50) +![curl-screenshot](https://codeberg.org/attachments/9bdd8005-5eea-4add-89c3-8efc61d06b6f) ![license](https://licensebuttons.net/p/zero/1.0/88x31.png) diff --git a/curl.sh b/curl.sh index 96b902f..4cb6b42 100755 --- a/curl.sh +++ b/curl.sh @@ -66,8 +66,11 @@ curl_cmd="$curl_cmd -o $RESP_BODY_RAW_FILE -D $RESP_HEADERS_FILE" # Execute curl eval "clear" -echo -e "${method} ${url}" +echo -e "\e[0;92mRequest >\e[0m ${method} ${url}" eval $curl_cmd # Copy the raw respone body to a pretty-printed JSON file jq . $RESP_BODY_RAW_FILE > $RESP_BODY_JSON_FILE + +# Print the response code +echo -e -n "\e[0;94mResponse <\e[0m "; awk 'NR==1{print $2, $3; exit}' $RESP_HEADERS_FILE