#!/bin/sh # Written by: John Ellson error() { echo "$0: $*" >&2; exit 1; } for prog in gvim vim ""; do if test -x /usr/bin/$prog; then break; fi if which $prog >&/dev/null; then break; fi done if test -z "$prog"; then error "the editor not found"; fi default="noname.dot" if test -z "$1"; then if test -s "$default"; then error "$default already exists" else f="$default" fi else f="$1" fi if [ ! -f "$f" ]; then if [ ! -w . ]; then error "directory `pwd` is not writable"; fi cat >"$f" < vimdot } EOF fi if [ ! -w "$f" ]; then error "$f is not writable"; fi # dot -Txlib watches the file $f for changes using inotify() dot -Txlib "$f" & # open an editor on the file $f (could be any editor; gvim &'s itself) exec $prog "$f"