Prompt on `app .. config` if $EDITOR is un-set
continuous-integration/drone/push Build is failing Details

Closes #41
This commit is contained in:
3wc 2020-12-31 12:52:44 +02:00
parent 8839bd4595
commit 29cc392dff
1 changed files with 25 additions and 0 deletions

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"
}