feat(fish): add random_free_port func

Amolith created

Change summary

dot_config/private_fish/functions/random_free_port.fish | 7 +++++++
1 file changed, 7 insertions(+)

Detailed changes

dot_config/private_fish/functions/random_free_port.fish 🔗

@@ -0,0 +1,7 @@
+function random_free_port --description 'Print a random unprivileged port not currently in use'
+    set -l p (shuf -i 1024-65535 -n 1)
+    while ss -tuln | string match -qr ":$p\$"
+        set p (shuf -i 1024-65535 -n 1)
+    end
+    echo $p
+end