Github CLI - Grep for filtering by phrase in pull request body?

942 Views Asked by At

I’m using the Github CLI tool, which includes a command gh pr list that allows you to see all the open pull requests.

The issue is that I only see a list of their titles and there’s a separate command gh pr view [extra info] that actually allows you to see the body.

I’m searching for pull requests that have a certain phrase in the BODY so gh pr list | grep “hello” wouldn’t work because it only gives me pull requests with “hello” in the header, and not necessarily the body.

How might I go about approaching this problem and are there any shortcuts in the github cli that might help me?

1

There are 1 best solutions below

0
On

Sicne gh pr list, like gh pr view, does inherit from the same option --json <fields> (Output JSON with the specified fields), you can use:

gh pr list --json number,body | grep "helllo"

That would grep for your specific message, and still give you an ID that you can use with gh pr view.