Source

pythonwise / start

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

# Miki Tebeka <miki@mikitebeka.com>

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

# Taken from http://pypi.python.org/pypi/desktop/0.3
linux_open()
{
    if [ -n "$GNOME_DESKTOP_SESSION_ID" ]; then
        if which gvfs-open > /dev/null; then
            echo "gvfs-open"
        else
            echo "gnome-open"
        fi
    elif [ -n "$KDE_FULL_SESSION" ]; then
        echo "kfmclient exec"
    elif xprop -root _DT_SAVE_MODE 2>&1 | grep -iq xfce; then
        echo "exo-open"
    else
        echo ""
    fi
}

case `uname` in
    Linux) open=`linux_open`;;
    Darwin) open=open;;
    CYGWIN*) open=cygstart;;
    MINGW*) open=start;;
esac

if [ -z "$open" ]; then
    echo "error: no start program for `uname` platform" 1>&2
    exit 1
fi

$open "$1" > /dev/null 2>&1
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.