aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDamien Lallement <dams@mageia.org>2012-05-03 11:07:30 +0000
committerDamien Lallement <dams@mageia.org>2012-05-03 11:07:30 +0000
commit6e53fbeb128c0987d564f6e94cb98bd5b7817e88 (patch)
tree3a419d59738830ba64034d263e5817a5128c7455 /bin
parentc4e4c68a0a5297d1e7b10a36de7b4195c08de468 (diff)
downloadcommon-data-6e53fbeb128c0987d564f6e94cb98bd5b7817e88.tar
common-data-6e53fbeb128c0987d564f6e94cb98bd5b7817e88.tar.gz
common-data-6e53fbeb128c0987d564f6e94cb98bd5b7817e88.tar.bz2
common-data-6e53fbeb128c0987d564f6e94cb98bd5b7817e88.tar.xz
common-data-6e53fbeb128c0987d564f6e94cb98bd5b7817e88.zip
add 'xte' script to find text editor
Diffstat (limited to 'bin')
-rwxr-xr-xbin/xte61
1 files changed, 61 insertions, 0 deletions
diff --git a/bin/xte b/bin/xte
new file mode 100755
index 0000000..63a5f5c
--- /dev/null
+++ b/bin/xte
@@ -0,0 +1,61 @@
+#!/bin/sh
+#---------------------------------------------------------------
+# Project : Mageia
+# Module : bin
+# File : xte
+# Author : David Walser
+# Created On : Thu Apr 3 16:26:54 2012
+# Purpose : launch a text editor
+#---------------------------------------------------------------
+
+strip_texteditor_var() {
+ if [[ -n "$TEXTEDITOR" ]]; then
+ if [[ `basename "$TEXTEDITOR"` == "xte" ]]; then
+ unset TEXTEDITOR
+ elif ! which $TEXTEDITOR > /dev/null 2>&1; then
+ unset TEXTEDITOR
+ fi
+ fi
+}
+
+strip_texteditor_var
+if [[ -z "$TEXTEDITOR" ]]; then
+
+ # using GNOME
+ if [[ -n "$GNOME_DESKTOP_SESSION_ID" ]]; then
+ TEXTEDITOR="gedit"
+ fi
+
+ #using KDE
+ if [[ -n "$KDE_FULL_SESSION" ]]; then
+ TEXTEDITOR="kwrite"
+ fi
+
+
+ strip_texteditor_var
+
+ [[ -z "$TEXTEDITOR" ]] && TEXTEDITOR=`which kwrite 2> /dev/null`
+ [[ -z "$TEXTEDITOR" ]] && TEXTEDITOR=`which gedit 2> /dev/null`
+
+ if [[ -z "$TEXTEDITOR" ]]; then
+ EMACS=`/usr/sbin/update-alternatives --list emacs`
+ if [[ -n "$EMACS" ]]; then
+ if [[ `basename "$EMACS"` = "emacs-nox" ]]; then
+ TEXTEDITOR="xvt -e emacs"
+ else
+ TEXTEDITOR="emacs"
+ fi
+ fi
+ fi
+
+ [[ -z "$TEXTEDITOR" ]] && which vim > /dev/null 2>&1 && TEXTEDITOR="xvt -e vim"
+ [[ -z "$TEXTEDITOR" ]] && which nano > /dev/null 2>&1 && TEXTEDITOR="xvt -e nano"
+fi
+
+if [[ -n "$TEXTEDITOR" ]]; then
+ exec $TEXTEDITOR $@
+else
+ echo "no text editor detected"
+fi
+
+# xte ends here