#!/usr/bin/env bash
set -euo pipefail

# Script Name: mksh
# Description: Rapidly create executable bash scripts with template
# Source: https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/

if [[ $# -ne 1 ]]; then
  echo 'mksh takes one argument' >&2
  exit 1
elif [[ -e "$1" ]]; then
  echo "$1 already exists" >&2
  exit 1
fi

cat > "$1" << 'EOF'
#!/usr/bin/env bash
set -euo pipefail

EOF

chmod +x "$1"

"${EDITOR:-vim}" "$1"
