local target="${1:-}" if [[ -z "$target" ]]; then echo "usage: nbash " return 1 fi # PREVENT OVERWRITES # exit immediately if the target file already exists if [[ -f "$target" ]]; then echo "error: file '$target' already exists." return 1 fi # CREATE DIRECTORIES # ensure the parent directory structure exists before creating the file mkdir -p "$(dirname "$target")" # TEMPLATE SELECTION # use the external template if available, otherwise generate inline local template="$HOME/.bash_templates/script.sh" if [[ -f "$template" ]]; then cp "$template" "$target" else cat > "$target" <