From e593efc410b5d0ae34cfe0bf7a4dcf6dcd37ea14 Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Thu, 22 Apr 2021 11:42:02 +0200 Subject: [PATCH] Add -c option to myip script --- script/myip | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/script/myip b/script/myip index c5bc450..c67840a 100755 --- a/script/myip +++ b/script/myip @@ -3,4 +3,15 @@ # Print public IP address set -e -curl -s 'https://api.ipify.org?format=text' + +url='https://api.ipify.org?format=text' + +if [ "$1" = "-c" ]; then + if [ $(uname -s) = "Darwin" ]; then + curl -s $url | pbcopy + else + curl -s $url | xclip -i + fi +else + curl -s $url +fi