Assorted shell and Python scripts

Add myip and delete_yum_repo

Changed files
+27 -19
+16
delete_yum_repo
···
+
#!/usr/bin/env zsh
+
+
selection=$(find /etc/yum.repos.d -type f -name "*.repo" | gum choose --no-limit)
+
+
format_string_array=(
+
"# You selected the following repo file(s):\n"
+
)
+
+
echo "$selection" | while read -r line; do format_string_array+=("- $line\n"); done
+
echo "${format_string_array[@]}" | gum format
+
echo ""
+
if gum confirm "Are you sure you want to delete?"; then
+
sudo rm -v $(echo "$selection")
+
else
+
echo ":raised_eyebrow: Oh, okay then. Carry on." | gum format -t emoji
+
fi
+11 -19
myip
···
#!/usr/bin/env python3
-
#
-
# myip - Fetch and display public IP information fro ipinfo.io
+
+
"""
+
myip - Fetch and display public IP information from ipinfo.io
+
"""
import json
import requests
-
-
class bcolors:
-
KEY = "\033[92m"
-
ENDC = "\033[0m"
-
-
@staticmethod
-
def colored(message: str, color: str):
-
return color + message + bcolors.ENDC
-
-
if __name__ == "__main__":
-
req = requests.get("https://ipinfo.io")
-
json_data = json.loads(req.text)
+
KEY_COLOR = "\033[92m"
+
END_COLOR = "\033[0m"
+
+
response = requests.get("https://ipinfo.io", timeout=60)
+
json_data = json.loads(response.text)
+
print()
for item in json_data:
-
print(
-
"- {:<20} {}".format(
-
bcolors.colored(item.title(), bcolors.KEY), json_data[item]
-
)
-
)
+
print(f"- {KEY_COLOR}{item.title():<16}{END_COLOR} {json_data[item]}")