MacOS open’s under Linux

MacOS has a nice “open” command that will open any document with any application from the command line. I hacked my own for Linux for a bash shell:


TEMP=`getopt -o a: -- "$@"`
if [ $? != 0 ] ; then exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
-a) COMMAND=$2 ; shift 2;;
--) shift ; break ;;
*)echo "should not happen" ; exit 1 ;;
esac
done
if [ $COMMAND ]; then
nohup $COMMAND $@ > ~/.s1 2> ~/.s2 &
else
/usr/bin/xdg-open $@
fi

4 thoughts on “MacOS open’s under Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *