about summary refs log tree commit diff
path: root/profile/.profile.d/open.sh
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>1970-01-01 03:00:00 +0300
committerAzat Bahawi <azat@bahawi.net>2022-09-20 11:51:54 +0300
commit38bab29776950ac2364ed64195b89887717c33de (patch)
treeedaaf366a55dbe96d268019124536bc504c64e87 /profile/.profile.d/open.sh
chore: init HEAD master
Diffstat (limited to 'profile/.profile.d/open.sh')
-rw-r--r--profile/.profile.d/open.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/profile/.profile.d/open.sh b/profile/.profile.d/open.sh
new file mode 100644
index 0000000..8d0cd22
--- /dev/null
+++ b/profile/.profile.d/open.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ "$(uname)" = "Linux" ]; then
+	if grep -q Microsoft /proc/version; then
+		alias open="explorer.exe"
+	elif command -v "xdg-open" >/dev/null 2>&1; then
+		alias open="xdg-open"
+	fi
+fi
+
+if command -v "open" >/dev/null 2>&1; then
+	o() {
+		if [ "${#}" -eq 0 ]; then
+			open "${PWD}"
+		else
+			open "${@}"
+		fi
+	}
+fi

Consider giving Nix/NixOS a try! <3