#!/bin/zsh
setopt no_unset extended_glob warn_create_global

die() {
	printf >&2 '%s\n' "$@"
	exit 1
}

main() {
	local container session=_
	[[ $1 == */* ]] && die "Invalid container name: ${(qqq)1}"
	container=$1
	shift 1 || exit $?
	if (($#)) && [[ $1 == -s ]]; then
		session=$2
		shift 2 || exit $?
	fi
	c.urxvt.named $container tmux-session-$session tmux -2u new-session -s $session -A "$@"
}
typeset -f -t main

main "$@"