Prompt on app .. config if $EDITOR is un-set

Closes #41
This commit is contained in:
3wc 2020-12-31 12:52:44 +02:00
parent 8839bd4595
commit 29cc392dff

25
abra
View File

@ -684,6 +684,31 @@ sub_app_undeploy (){
sub_app_config (){
load_instance
if [ -z "$EDITOR" ]; then
warning "\$EDITOR not set; which text editor would you like to use?"
EDITORS_ALL=(vi vim nano pico emacs)
declare -a EDITORS_AVAILABLE
for EDITOR in "${EDITORS_ALL[@]}"; do
if type "$EDITOR" > /dev/null 2>&1; then
EDITORS_AVAILABLE+=("$EDITOR")
fi
done
if [ ${#EDITORS_AVAILABLE[@]} = 0 ]; then
error "No text editors found! Are you using a magnetised needle? 🤪"
fi
select EDITOR in "${EDITORS_AVAILABLE[@]}"; do
if [ 1 -le "$REPLY" ] && [ "$REPLY" -le ${#EDITORS_AVAILABLE[@]} ]; then
SERVER="$EDITOR"
success "Using '${EDITOR}'; Add 'export EDITOR=${EDITOR}' to your ~/.bashrc to set as default"
break
fi
done
fi
$EDITOR "$ENV_FILE"
}