Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Created April 30, 2012 11:57
Show Gist options
  • Save tlatsas/2557638 to your computer and use it in GitHub Desktop.
Save tlatsas/2557638 to your computer and use it in GitHub Desktop.
pentadactyl - get ip address function
function ip() {
var req = new XMLHttpRequest();
req.open('GET', 'http://checkip.dyndns.org/', true);
req.onreadystatechange = function (ev) {
if (req.readyState == 4) {
var ip_re = /[0-9]+.[0-9]+.[0-9]+.[0-9]+/g;
try {
dactyl.echo(req.responseText.match(ip_re)[0]);
}
catch (err) {
dactyl.echo(err);
}
}
}
req.send(null);
}
/*
* map in pentadactyl with:
* command ip -js ip()
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment