dotfiles/script/ghco

24 lines
479 B
Plaintext
Raw Permalink Normal View History

2021-03-31 10:47:59 +00:00
#!/usr/bin/env bash
# Select and checkout a GitHub pull request using the GitHub CLI (required)
set -e
2021-04-23 01:57:17 +00:00
export GH_NO_UPDATE_NOTIFIER=1
unset BROWSER
2021-04-23 01:57:17 +00:00
2021-08-13 08:07:28 +00:00
if [ "$1" = '-a' ]; then
cmd='gh pr list --limit 100'
elif [ -z "$GITHUB_USERNAME" ]; then
2023-10-07 08:43:32 +00:00
# shellcheck disable=SC2016
2021-08-13 08:07:28 +00:00
echo 'set $GITHUB_USERNAME first'
exit 1
else
cmd="gh pr list --author $GITHUB_USERNAME"
fi
prid=$(eval "$cmd" | fzf | awk '{print $1}')
2023-10-07 08:43:32 +00:00
if [ -z "$prid" ]; then
2021-03-31 10:47:59 +00:00
exit 0
fi
2023-10-07 08:43:32 +00:00
gh pr checkout "$prid"