Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Script example for Command Line Mongrals' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Script example for Command Line Mongrals
Authored by: ktohg on Jan 21, '03 02:44:03AM
My text editor (VIM) has both an X11 version and a MacOS version. I prefer the X11 one but don't always have X11 running. So I created a script to select the prefered version depending. It's a sample that you can use.
#!/bin/sh showhelp() { cat <<EOF This is a wrapper script for the graphical version of VIM. The script recognizes the following command line options. Only the first option will be recognized.    -h              This cruft    --help          vim --help    -x, --x11       force X11 gvim (Start X Server if                    not one already runnung)    -X, --no-x11    force MacOS gvim    --              NO-OP (pass remaining options as-is) If you do not force a display method one will be guessed based on the DISPLAY environment variable and the presence of X11.app running. EOF } case "$1" in    --) shift; X11=ukn;;    -h|-help) showhelp; exit -1;;    --help) exec vim --help;;    -x|--x11)  shift; X11=yes;;    +x|-X|--no-x11)  shift; X11=no;;    *)  X11=ukn;; esac case `basename "$0"` in    xvim) X11=yes;;    mvim) X11=no;; esac if [ -z "$DISPLAY" ]; then    if [ -z "`ps ax | grep X11.app | grep -v grep`" ]; then        if [ $X11 == yes ]; then            open -a X11            sleep 5            export DISPLAY=:0        else            X11=no        fi    elif [ $X11 != no ]; then        export DISPLAY=:0        X11=yes    fi elif [ $X11 != no ]; then    X11=yes fi case "$X11" in    yes) exec vim -g $*;;    no)  exec open -a Vim $*;; esac


[ Reply to This | # ]