#!/bin/bash run() { local editor=$1; shift local cmd IFS='|' cmd=($(eval printf '%s\|' "$editor")) cmd+=("$@") "${cmd[@]}" } (if [ -n "$DISPLAY" ]; then run "${VISUAL:-$SELECTED_EDITOR}" "$@" else run "${EDITOR:-$SELECTED_EDITOR}" "$@" fi) || run "${ALTERNATE_EDITOR:-false}" "$@"