#!/bin/sh -e
#
# o - open a path/file/link with default system app or current dir when no argument provided
# dependencies: os-detect

case $(os-detect) in
  windows_wsl) wslview "${*:-.}" ;;
  windows_cygwin) cygstart "${*:-.}" ;;
  windows_m*) start "${*:-.}" ;;
  osx) $(command -v open || command -v xdg-open) "${*:-.}" ;;
  linux*) DISPLAY=:1 xdg-open "${*:-.}" ;;
  *)
    echo "Unknown operating system and open command, please log an issue"
    exit 1
    ;;
esac
