obosdi-pkg/config/bash/editor

36 lines
664 B
Text
Raw Normal View History

2015-11-01 13:11:17 -07:00
#!/bin/bash
. ./lib
options=()
2018-09-15 19:36:14 -06:00
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
2015-11-01 13:11:17 -07:00
options+=("unset" "")
2022-11-10 14:27:23 -07:00
editor=$(dialog --backtitle "$apptitle" --title "Default global editor :" --cancel-button "Back" --menu "" 0 0 0 \
2015-11-01 13:11:17 -07:00
"${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
2019-01-02 18:00:59 -07:00
export EDITOR=$editor
2015-11-01 13:11:17 -07:00
fi
exit 0