Last active
December 23, 2024 19:21
-
-
Save theodric/685af2d1eb4d551640eeb776b5eac3e9 to your computer and use it in GitHub Desktop.
macOS 'open' for bash on linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open() { | |
if [[ -z "$1" ]]; then | |
echo "usage: open <file>" >&2 | |
return 1 | |
fi | |
if [[ ! -e "$1" ]]; then | |
echo "file not found: $1" >&2 | |
return 1 | |
fi | |
command -v xdg-open >/dev/null 2>&1 || { | |
echo "xdg-open not found; install it or figure out an alternative" >&2 | |
return 1 | |
} | |
xdg-open "$1" &>/dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment