#!/bin/bash

case "$1" in
    --nedit) shift; exec nedit "$@"
        ;;
    --glimmer) shift; exec glimmer "$@"
        ;;
    --bluefish) shift; exec bluefish "$@"
        ;;
    --vi) shift; exec xterm -T "VIM: $file" ${file:+-n $file} -name VIM -e vim "$@"
        ;;
esac

if [ -n "$1" ]; then
    if [ -d "$1" ]; then
        cd "$1"
        shift
    else
	cd "$(dirname "$1")"
    fi
    case "$1" in
        # just an example
        *.py|*.pl) exec glimmer "$@" ;;
        *) exec nc "$@" ;;
    esac
else
    exec nc
fi
