35 lines
664 B
Bash
35 lines
664 B
Bash
#!/bin/bash
|
|
. ./lib
|
|
|
|
options=()
|
|
if [ -f /usr/bin/nano ]; then
|
|
options+=("nano" "")
|
|
fi
|
|
if [ -f /usr/bin/vim ]; then
|
|
options+=("vim" "")
|
|
fi
|
|
if [ -f /usr/bin/vi ]; then
|
|
options+=("vi" "")
|
|
fi
|
|
if [ -f /usr/bin/edit ]; then
|
|
options+=("edit" "")
|
|
fi
|
|
options+=("unset" "")
|
|
|
|
editor=$(dialog --backtitle "$apptitle" --title "Default global editor :" --cancel-button "Back" --menu "" 0 0 0 \
|
|
"${options[@]}" \
|
|
3>&1 1>&2 2>&3)
|
|
if [ ! "$?" = "0" ]; then
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$editor" = "unset" ]; then
|
|
rm /etc/profile.d/editor.sh
|
|
else
|
|
echo "export EDITOR=$editor" > /etc/profile.d/editor.sh
|
|
chmod 755 /etc/profile.d/editor.sh
|
|
export EDITOR=$editor
|
|
fi
|
|
|
|
exit 0
|
|
|