#!/bin/bash
# gopen: open a file using appropriate program
# Usage: gopen <filename>

if [ $# -eq 0 ]; then
   echo "Usage: gopen <file>"
   exit 1
fi

if [[ "$1" == *.ipynb ]] || [[ "$1" == *.py.gnb.md ]]; then
    python -i $GTERM_DIR/bin/gpylab.py $1
else
    if which xdg-open > /dev/null; then
	xdg-open "$1" &> /dev/null &
    elif which gnome-open > /dev/null; then
	gnome-open "$1"
    elif which open > /dev/null; then
	open "$1"
    else
	echo "No open command found!"
	exit 1
    fi
fi
