blob: f5045e7460931b17b16174398ade4b0a0f9f45ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/bin/sh
#---------------------------------------------------------------
# Project : Mageia
# Module : bin
# File : editor
# 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"` == "editor" ]]; 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
TEXTEDITOR="emacs"
fi
fi
[[ -z "$TEXTEDITOR" ]] && which vim > /dev/null 2>&1 && TEXTEDITOR="vim"
[[ -z "$TEXTEDITOR" ]] && which nano > /dev/null 2>&1 && TEXTEDITOR="nano"
fi
if [[ -n "$TEXTEDITOR" ]]; then
exec $TEXTEDITOR "$@"
else
echo "no text editor detected"
fi
# editor ends here
|