Skip to content

Instantly share code, notes, and snippets.

@MichaelDimmitt
Last active November 15, 2023 17:09
Show Gist options
  • Save MichaelDimmitt/f9931a66bfc24e40e91aa4c8ec52cdd1 to your computer and use it in GitHub Desktop.
Save MichaelDimmitt/f9931a66bfc24e40e91aa4c8ec52cdd1 to your computer and use it in GitHub Desktop.
open_command.sh
__find_open_command_from_Operating_System() {
local open_cmd
OSTYPE="$(uname -s | tr 'A-Z' 'a-z')"
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""'
} ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
echo "$open_cmd"
}
# run the function and use it to open https://www.google.com, see below:
$(__find_open_command_from_Operating_System) https://www.google.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment