Skip to content

Instantly share code, notes, and snippets.

@mahelbir
Created September 28, 2026 19:25
Show Gist options
  • Select an option

  • Save mahelbir/b8fb37bf6ac92825e06237861d7cb9ad to your computer and use it in GitHub Desktop.

Select an option

Save mahelbir/b8fb37bf6ac92825e06237861d7cb9ad to your computer and use it in GitHub Desktop.
Cloudflare Quick Tunnels
cfd() {
local port=$1
cloudflared tunnel --url "http://localhost:$port" 2>&1 | while IFS= read -r line; do
echo "$line"
if echo "$line" | grep -qE 'https://[a-zA-Z0-9.-]+\.trycloudflare\.com'; then
local url=$(echo "$line" | grep -oE 'https://[a-zA-Z0-9.-]+\.trycloudflare\.com')
if command -v pbcopy &>/dev/null; then
echo -n "$url" | pbcopy
elif command -v xclip &>/dev/null; then
echo -n "$url" | xclip -selection clipboard
elif command -v wl-copy &>/dev/null; then
echo -n "$url" | wl-copy
fi
echo ""
echo "URL: $url"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment