If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Tuesday, August 21, 2007

start

Many times, I open files from the command line.
However each OS has it's own utility for opening file, so I have this little script called start (yes, I started my life on windows ;).

#!/bin/bash
# Open a file from command line, multi OS

# Miki Tebeka <miki.tebeka@gmail.com>

if [ $# -ne 1 ]; then
echo "usage: `basename $0` PATH"
exit 1
fi

if [ ! -e $1 ]; then
echo "error: can't find $1" 1>&2
exit 1
fi

case `uname` in
Linux) open=exo-open;;
Darwin) open=open;;
CYGWIN*) open=cygstart;;
MINGW32*) open=start;;
*) echo "error: no start program for `uname` platform" 1>&2; exit 1;;
esac

$open "$1"
Post a Comment

Blog Archive