aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/open
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-01-16 15:05:53 +0100
committerPatrick Spek <p.spek@tyil.nl>2020-01-16 15:05:53 +0100
commit6f736b919a4da2fa8aecef046f8785bc110bd6f4 (patch)
tree5ad34f52cf9d8bd8c95cd4c85e09768926adfbe4 /.local/bin/open
parent3211d0aff5e9e515755e7316739fa45c99392f57 (diff)
Add small utility to open things (WIP)
Diffstat (limited to '.local/bin/open')
-rwxr-xr-x.local/bin/open29
1 files changed, 29 insertions, 0 deletions
diff --git a/.local/bin/open b/.local/bin/open
new file mode 100755
index 0000000..f3391d7
--- /dev/null
+++ b/.local/bin/open
@@ -0,0 +1,29 @@
+#! /usr/bin/env raku
+
+use URL;
+
+sub MAIN ($target)
+{
+ my URL $url .= new($target);
+
+ if (!$url.scheme) {
+ run « xdg-open "$target" »;
+ exit 0;
+ }
+
+ given $url.scheme.fc {
+ when 'http'|'https' {
+ given $url.hostname.fc {
+ when *.ends-with('aws.amazon.com') { run « chromium-browser "$url" » }
+ when *.ends-with('google.com') { run « chromium-browser "$url" » }
+ when *.ends-with('slack.com') { run « chromium-browser "$url" » }
+ when *.ends-with('zaaksysteem.net') { run « chromium-browser "$url" » }
+ when *.ends-with('zaaksysteem.nl') { run « chromium-browser "$url" » }
+ default { run « "%*ENV<BROWSER>" "$url" » }
+ }
+ }
+ default {
+ run « xdg-open "$url" »;
+ }
+ }
+}