aboutsummaryrefslogtreecommitdiffstats
path: root/bin/editor
blob: 057b977524c1c45bfec72901c4d3530e7829a94e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
# launch a text editor

exec_editor() {
    if [ -n "$1" ] && [ $(basename "$1") != "editor" ] \
        && which "$1" > /dev/null 2>&1
    then
        exec "$@"
    fi
}

exec_editor "$TEXTEDITOR" "$@"
[ -n "$GNOME_DESKTOP_SESSION_ID" ] && exec_editor gedit "$@"
[ -n "$KDE_FULL_SESSION" ] && exec_editor kwrite "$@"
exec_editor kwrite "$@"
exec_editor gedit  "$@"
exec_editor emacs  "$@"
exec_editor vim    "$@"
exec_editor nano   "$@"

echo "no text editor detected" >&2
exit 1