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 Comments

  1. If you are running GNOME, you can also use the command “gnome-open”.

    Comment by Jo Vermeulen — 22/9/2008 @ 4:06

  2. Hmmm, it’s not completely equivalent because “gnome-open” doesn’t allow you to choose the application you want to use, it always uses the default one.

    Comment by Jo Vermeulen — 22/9/2008 @ 4:54

  3. And… if a given file type has no default application? Then gnome-open fails.

    Comment by Daniel Lemire — 22/9/2008 @ 6:22

  4. Plus, what if you are not using gnome?

    Comment by Daniel Lemire — 22/9/2008 @ 6:23

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

« Blog's main page

Additional comments powered by BackType

19 queries. 0.413 seconds. Valid XHTML

Powered by WordPress

Subscribe to this blog in a reader or by Email.