I'll join in too - here's mine
swaywm
dedicated to the Sway window manager, a drop-in replacement for the i3 window manager, but for Wayland instead of X11.
#!/bin/bash
w=$(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1)+ 1))
i3-msg move container to workspace $w
i3-msg workspace $w
i3-msg move workspace to output $1
Here's my version. It's a little different than yours and is obviously for i3. I have it bound to display specific shortcuts, so I can send the focused window to a new empty workspace on the display of my choosing.
I also don't use a set number of workspaces, I have 4 primary, one for each display. And I have shortcuts to switch to the primary on a given display, and then other shortcuts to cycle the active workspace on that display. So the above may not work for everyone, but it is another option. I assume it would require only minor modification to work with Sway.
Edit: I suppose I should provide an explanation. That first line just gets the highest workspace number currently in use and adds 1 to it. Then the rest is pretty straightforward. It moves the container to the the workspace with the new number (i3 creates a new workspace for this) and then brings it into focus, and finally moves it to the display requested.