elvish_config/aliases/ipinfo.elv

19 lines
368 B
Plaintext
Raw Normal View History

2021-12-11 21:09:02 +00:00
edit:add-var ipinfo~ {|@argv|
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
2021-08-24 18:45:25 +00:00
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|
printf 'ipinfo.io/%s?token=%s' $ip $token
2021-08-24 18:45:25 +00:00
}
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)
printf "URL: %s\n" $url
2021-08-24 18:45:25 +00:00
e:curlie $url
}
}
each $info~ $argv
}