elvish_config/aliases/ipinfo.elv

20 lines
344 B
Plaintext
Raw Normal View History

2021-12-11 21:09:02 +00:00
edit:add-var ipinfo~ {|@argv|
2021-08-24 18:45:25 +00:00
use moi/util/ip
use str
var token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
2021-08-24 18:45:25 +00:00
2021-12-11 21:09:02 +00:00
fn url-of {|ip|
2021-08-24 18:45:25 +00:00
str:join '' [ 'ipinfo.io/' $ip '?token=' $token]
}
2021-12-11 21:09:02 +00:00
fn info {|ip|
2021-08-24 18:45:25 +00:00
if (ip:is-ip $ip) {
var url = (url-of $ip)
2021-08-24 18:45:25 +00:00
echo 'URL: '$url
e:curlie $url
}
}
each $info~ $argv
}