dotfiles/script/ghci

25 lines
458 B
Plaintext
Raw Permalink Normal View History

2021-07-27 07:46:44 +00:00
#!/usr/bin/env bash
#
# Open GitHub CI for the current branch
set -e
export GH_NO_UPDATE_NOTIFIER=1
unset BROWSER
2021-07-27 07:46:44 +00:00
2021-07-29 06:49:01 +00:00
# GitHub CLI returns non-zero error code if checks are not complete:
ghoutput=$(gh pr checks || true)
if ! echo "$ghoutput" | grep -q 'https://'; then
2021-07-27 07:46:44 +00:00
exit 1
fi
2023-10-07 08:43:32 +00:00
url=$(echo "$ghoutput" | grep -o 'https://.*?' | tr -d '?')
2021-07-27 07:46:44 +00:00
2023-10-07 08:43:32 +00:00
if [ "$(uname -s)" = "Linux" ]; then
2021-07-27 07:46:44 +00:00
progname="xdg-open"
else
progname="open" # macOS
fi
eval "$progname $url"