eg (394B)
1 #!/usr/bin/env bash 2 set -Eeo pipefail 3 4 if [ $# -eq 0 ]; then 5 1>&2 echo "no arguments provided" 6 exit 1 7 fi 8 9 REGEX="$1" 10 shift 11 12 MATCHES="`ag -l --no-color "${REGEX}" $@`" 13 14 if test -z "${MATCHES}"; then 15 1>&2 echo "no results match regex" 16 exit 2 17 else 18 if [[ $EDITOR == *vim ]]; then 19 eval $EDITOR +/\"${REGEX}\" ${MATCHES} 20 else 21 eval $EDITOR ${MATCHES} 22 fi 23 fi