Last active
April 10, 2026 16:41
-
-
Save dfl/292205981bd612486e3640f04ed2954b to your computer and use it in GitHub Desktop.
Generate PR link for Slack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| pr_url="$1" | |
| if [ -z "$pr_url" ]; then | |
| pr_url="$(pbpaste)" | |
| if [[ "$pr_url" =~ ^https://github\.com/.+/pull/[0-9]+ ]]; then | |
| echo "Using PR URL from clipboard: $pr_url" | |
| else | |
| echo "Usage: slapr <github-pr-url>" | |
| echo "Copies a Slack-formatted PR link to clipboard" | |
| echo "You can provide an argument, or simply copy the GitHub PR URL and run slapr with no args" | |
| exit 1 | |
| fi | |
| fi | |
| title=$(gh pr view "$pr_url" --json title --jq '.title' | sed 's/‑/-/g') | |
| swift - "$pr_url" "$title" << 'SWIFT' | |
| import AppKit | |
| let args = CommandLine.arguments | |
| let url = args[1] | |
| let title = args[2] | |
| let q = "\"" | |
| let html = "<meta charset='utf-8'><span data-stringify-emoji=" + q + ":pr_open:" + q + ">:pr_open:</span> <a href='" + url + "'>" + title + "</a>" | |
| let pb = NSPasteboard.general | |
| pb.clearContents() | |
| pb.setString(html, forType: .html) | |
| pb.setString(":pr_open: " + title, forType: .string) | |
| SWIFT | |
| echo "copied to clipboard! :pr_open: $title" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
new version: uses clipboard contents automatically if present, so no need to paste as command argument!