dotfiles/script/myip

18 lines
258 B
Plaintext
Raw Permalink Normal View History

2021-04-03 09:08:41 +00:00
#!/usr/bin/env bash
#
# Print public IP address
set -e
2021-04-22 09:42:02 +00:00
url='https://api.ipify.org?format=text'
if [ "$1" = "-c" ]; then
2023-10-07 08:43:32 +00:00
if [ "$(uname -s)" = "Darwin" ]; then
curl -s "$url" | pbcopy
2021-04-22 09:42:02 +00:00
else
2023-10-07 08:43:32 +00:00
curl -s "$url" | xclip -i
2021-04-22 09:42:02 +00:00
fi
else
2023-10-07 08:43:32 +00:00
curl -s "$url"
2021-04-22 09:42:02 +00:00
fi