chiark / gitweb /
bash_profile: Make editor selection indirect via a script mdw-editor.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 15 Feb 2007 21:37:47 +0000 (21:37 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 15 Feb 2007 21:46:10 +0000 (21:46 +0000)
This involves installing scripts from this package into the right place
in ~/bin.

bash_profile
mdw-editor [new file with mode: 0755]
setup

index c290aa97892bcdd07704aab2dc069d847164f5e8..3da56a881c120bad27cbaf40b1bdf481c7ca3568 100644 (file)
@@ -104,15 +104,16 @@ export QMAILINJECT=c
 
 # --- Find a text editor ---
 
-export EDITOR=ed
+export MDW_EDITOR=ed
 for ed in "emacs21 -nw" "emacs -nw" vi pico nano ae; do
   name=`echo $ed | sed 's/ .*$//'`
   if __mdw_programp "$name"; then
-    EDITOR=$ed
+    MDW_EDITOR=$ed
     break
   fi
 done
-export VISUAL="$EDITOR"
+
+export EDITOR=mdw-editor VISUAL=mdw-editor
 
 # --- Various options for programs ---
 
diff --git a/mdw-editor b/mdw-editor
new file mode 100755 (executable)
index 0000000..cca7310
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+set -e
+editor=${MDW_EDITOR-ed}
+case "$EDITOR,$VISUAL,$TERM" in
+  mdw-editor,mdw-editor,dumb) editor=gnuclient;;
+  mdw-editor,mdw-editor,*);;
+  *,mdw-editor,*) editor=$EDITOR;;
+  mdw-editor,*,*) editor=$VISUAL;;
+esac
+exec $editor "$@"
diff --git a/setup b/setup
index caa7b4bdd13ba5827844a1c7899f7c415804e18b..3978ff4b91cb138bf45d90f019d0e76c5e28b135 100755 (executable)
--- a/setup
+++ b/setup
@@ -157,7 +157,6 @@ dotfiles="
   e-keybindings.cfg:.enlightenment/keybindings.cfg
   evnc-keybindings.cfg:.enlightenment-vnc/keybindings.cfg
   jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg"
-mkdir -p $HOME/test
 echo "Installing dotfiles..."
 for d in $dotfiles; do
   target=.$d
@@ -173,6 +172,19 @@ for d in $dotfiles; do
 done
 echo " all done."
 
+### Install useful scripts included in this package
+scripts="
+  mdw-editor"
+echo "Installing scripts..."
+mkdir -p $HOME$sub/bin
+for s in $scripts; do
+  ft=$HOME$sub/bin/$s
+  ln -s $here/$s $ft.new
+  mv $ft.new $ft
+  echo "  $s"
+done
+echo " all done."
+
 ### Set up the Emacs config
 $echon "Finding a suitable emacs:$echoc"
 emacs=no