#!/usr/bin/env bash

set -euo pipefail # Safe, strict script execution

if [[ $# == 0 ]]; then
  >&2 echo "USAGE: mkbin-edit <file> [<args for \$EDITOR>]"
  exit 1
fi

FILE_NAME="$1"; shift

touch "$FILE_NAME"
chmod +x "$FILE_NAME"

# We pass the rest of the args, to be able to write:
#     mkbin-edit some/file +"setf sh"
# to set the filetype to sh in (neo)vim
"${EDITOR:-nvim}" "$FILE_NAME" "$@"
