Can your one line terminal invocation automatically put the MacBook to sleep when you are connected via ssh and the connection is lost?
Technically one line ;)
sudo bash -c 'trap "pmset -a disablesleep 0" EXIT; s=; while :; do if lsof -nP -iTCP:22 -sTCP:ESTABLISHED >/dev/null 2>&1 || pgrep -xq ssh; then n=1; else n=0; fi; [ "$n" != "$s" ] && pmset -a disablesleep $n && s=$n; sleep 10; done'
Technically one line ;)