gh-pr-view
View pull request details
TLDR
View the pull request associated with the current branch
View a specific pull request
Open the pull request in the default web browser
Show comments in the terminal
SYNOPSIS
gh pr view [PR-NUMBER | PR-URL | BRANCH] [OPTIONS]
PARAMETERS
PR-NUMBER
The numerical ID of the pull request to view.
PR-URL
The full URL of the pull request.
BRANCH
The name of the branch associated with the pull request.
-c, --cached
Optional. View cached pull request information, skipping a fresh fetch from the remote.
-d
Optional. Specify the number of context lines to show around diff hunks.
-w, --word-diff
Optional. Show differences on a word-by-word basis.
-s, --stat
Optional. Display a summary of changes, showing additions, deletions, and file modifications.
-b
Optional. The base branch to use for comparing changes. Defaults to the pull request's base branch.
-B, --browser
Optional. Open the pull request in your default web browser.
--no-color
Optional. Disable colored output in the terminal.
--unified
Optional. Force a unified diff format.
--comments
Optional. Explicitly show comments. (Often default behavior).
--no-comments
Optional. Hide all comments associated with the pull request.
--summary
Optional. Show a brief summary of the pull request and exit.
--header
Optional. Show a header in addition to the summary when using --summary.
--json
Optional. Output the pull request data in JSON format.
--oneline
Optional. Output a concise summary of the pull request on a single line.
--web
Optional. An alias for --browser, opening the pull request in a web browser.
--help
Optional. Display help information for the command.
DESCRIPTION
The gh-pr-view command is a powerful GitHub CLI extension designed to enhance the experience of reviewing pull requests directly from your terminal. It provides an interactive pager that displays comprehensive details about a pull request, including its description, status, associated diffs, and comments. With features like syntax highlighting for code changes and customizable diff contexts, developers can efficiently review code without needing to switch to a web browser. It supports viewing pull requests by number, URL, or branch name, making it highly flexible. Beyond just viewing, it offers options to show word-level diffs, diff statistics, or even open the pull request directly in a web browser. This tool significantly streamlines the pull request review workflow for command-line aficionados.
CAVEATS
The gh-pr-view command is a GitHub CLI extension, not a built-in gh command. It must be installed separately using gh extension install ddr/gh-pr-view. Its functionality relies on the GitHub CLI being properly authenticated and configured. Performance may vary with very large diffs or numerous comments, and network connectivity is required for fresh fetches.
INSTALLATION
To use gh-pr-view, you must first install it as a GitHub CLI extension:
gh extension install ddr/gh-pr-view
Ensure you have the GitHub CLI installed and authenticated before attempting to install the extension.
CONFIGURATION
The behavior of gh-pr-view can be influenced by standard Git and GitHub CLI configurations, such as your default pager (e.g., LESS environment variable). Customizations for diff context and other display settings are handled directly via command-line flags.
INTERACTION
When viewing a pull request, the command typically uses a pager like less, allowing you to navigate the content using standard pager commands (e.g., arrow keys for scrolling, q to quit). The content includes the PR's description, status, formatted diffs, and comments.
HISTORY
The gh-pr-view command was developed by ddr as a community extension for the GitHub CLI. It emerged from the need for a more robust and interactive command-line interface for reviewing pull requests, going beyond the basic summary provided by the core gh pr view command. Its development leverages the extensibility of the GitHub CLI, allowing users to augment its capabilities with custom tools. Since its initial release, it has gained popularity among developers who prefer a terminal-centric workflow, continually evolving with new features and improvements driven by community contributions and feedback.


