You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
944 B
Plaintext

2 years ago
#!/usr/bin/perl
# Opens what you would expect. If there is no argument passed to it
# checks if this is a GitHub repo and if so opens it with the gh tool in
# your browser. Otherwise, it checks if the argument is a file in the
# current directory and opens it with the default application (xdg-open).
# Finally, it assumes it is a URL, ensures begins with https:// and
# opens it in a new window with Firefox.
use v5.14;
$_ = shift;
if (not $_) {
my $gh = (grep {/github/ && s,git@,, && s,:,/, && s/\.git$//}
qx{git remote get-url --all origin})[0];
# $gh and exec 'firefox', '-new-window', "https://$gh";
$gh and exec 'google-chrome', "https://$gh";
}
if (/\.md$/) {
`pandoc -s -o /tmp/index.html $_ 2>/dev/null`;
exec 'lynx', '/tmp/index.html';
}
-r $_ && exec 'xdg-open', $_;
m,^http, or s,^,https://,;
-x '/mnt/c/Windows/explorer.exe' and exec 'explorer.exe', $_;
exec 'google-chrome', $_;