~duncan-bayne/setups

c6a3f3200fda6ced53f6b2591197373a308bd591 — Duncan Bayne a month ago 8a16798
Add script to open a given GitHub issue in a browser
1 files changed, 32 insertions(+), 0 deletions(-)

A mint/conf/bin/,go
A mint/conf/bin/,go => mint/conf/bin/,go +32 -0
@@ 0,0 1,32 @@
#!/usr/bin/env bash

set -euo pipefail
shellcheck "$0"

if [ "$#" -lt 1 ] || [ "${1-}" = "--help" ]; then
    {
  echo "Usage: ,go [ISSUENUM, ...]"
  echo
  echo "Opens the specified issue(s) for this repo in a browser."
  echo
  echo "If one ISSUENUM is passed, it opens just that one. If more than one"
  echo "ISSUENUM is passed, it opens them all."
  echo
  echo
  echo "Assumes the cwd is within the Git repo of interest."
    } 1>&2
    exit 1;
fi

url_for() {
    ISSUENUM=$1
    JSON=$(gh issue view "$ISSUENUM" --json "url")
    URL=$(echo "$JSON" | jq .url | sed 's/"//g')
    echo -n "$URL"
}

for issue_num in "$@"; do
  xdg-open "$(url_for $issue_num)" &
done