dotfiles/script/ghco

23 lines
445 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
echo 'set $GITHUB_USERNAME first'
exit 1
else
cmd="gh pr list --author $GITHUB_USERNAME"
fi
prid=$(eval "$cmd" | fzf | awk '{print $1}')
2021-03-31 10:47:59 +00:00
if [ -z $prid ]; then
exit 0
fi
gh pr checkout $prid