Skip to content

Instantly share code, notes, and snippets.

@paatsinsuwan
Last active April 11, 2024 16:03
Show Gist options
  • Save paatsinsuwan/4e89944b3fdb7fc189224cd5d581adfe to your computer and use it in GitHub Desktop.
Save paatsinsuwan/4e89944b3fdb7fc189224cd5d581adfe to your computer and use it in GitHub Desktop.
Add Github preview checkout for reviewing
# Adding Github PR preview function
# required: gh - install `brew install gh`
# required: fzf - install `brew install fzf`
# put this file in ~ (home directory) where all the dotfiles are
# add `source ~/.ghprrc` to your shell rc file (.bashrc, .zshrc)
# open a new Terminal window to activate this script
# to run function
# from a new Terminal window
# type in `ghpr`
function ghpr() {
GH_FORCE_TTY=100% gh pr list | fzf --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down --header-lines 3 | awk '{print $1}' | xargs gh pr checkout
}
# source credit
# this video https://www.youtube.com/watch?v=Bwzi63hEXwc
# by Elijah Manor
# https://www.youtube.com/@ElijahManor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment