|
|
Script example for Command Line Mongrals
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 |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|