#compdef docker-enter _docker-enter() { local state _arguments -C '1: :->container' case $state in (container) compadd -- $(docker ps --format '{{.Names}}');; esac } _docker-enter "$@"