#!/bin/sh get_in_path_except_current() { which -a "$1" | grep -A1 "$0" | grep -v "$0" } code="$(get_in_path_except_current code)" if [ -n "$code" ]; then exec "$code" "$@" elif [ "$(command -v code-insiders)" ]; then exec code-insiders "$@" else echo "code or code-insiders is not installed" >&2 exit 127 fi