Skip to content

Instantly share code, notes, and snippets.

@bjtitus
Last active August 26, 2020 03:17
Show Gist options
  • Save bjtitus/b1406a4981c5b6a6f5b6eaf21dce20cc to your computer and use it in GitHub Desktop.
Save bjtitus/b1406a4981c5b6a6f5b6eaf21dce20cc to your computer and use it in GitHub Desktop.
GH Tools
# Lists Github issues assigned to you
function gh-issues --description 'Interactively selects Issues'
gh issue view (gh issue list -a 'bjtitus' | sed '/^.*✓/ d' | sed '/^$/d' | fzf --tac --color=16 | grep -oE "\d+" | head -1)
end
# Fetches a list of open PRS created by you. Lists the PRs on a single line each.
function gh-open --description 'List Open PRs and Issues'
gh api graphql --paginate -f query='
{
viewer {
pullRequests(first: 10, states: OPEN, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
title
state
url
number
reviewDecision
repository {
owner {
login
}
name
}
}
}
}
}' | jq '.[] | .viewer.pullRequests.nodes[] | "(\(.repository.owner.login)/\(.repository.name)) \(.title) - \(.url)"'
end
# Opens a list of your open PRs to interactively select and view. Any [flags] are passed to the `gh pr view` command.
# Usage: gh-prs-open [flags]
function gh-prs-open --description 'Select and view an open pr' -a flags
gh pr view $flags (gh-open | fzf --tac --color=16 | grep -oE "\- .*" | sed 's/- //g')
end
# Lists relevant PRs (current branch, created by you, assigned to you) for the current repo and allows you to interactively select them for checkout.
function gh-prs --description 'Interactively selects PRs'
gh pr checkout (gh pr status | sed '/^.*✓/ d' | sed '/^$/d' | fzf --tac --color=16 --header-lines=1 | grep -oE "#\d+" | sed 's/#//g')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment