feat(shell): add prr zsh plugin

This will use my directory structure to get the project namespace and
name for prr. This way we dont need to keep providing the extra info.
This commit is contained in:
Ade Attwood 2023-08-21 08:35:09 +01:00
parent debce210d5
commit 835d695ed0

View file

@ -0,0 +1,22 @@
# Gets the git project name "owner/repo" from the current directory. This uses
# the directory structure like the `GOPATH` this is aliased to `~s`. For
# example the directory would be `~/github.com/AdeAttwood/Dotfiles`, this would
# return `AdeAttwood/Dotfiles`.
function get_project() {
echo "$(basename "$(dirname "$PWD")")/$(basename "$PWD")"
}
# Gets the PR number from the current git repo and branch.
function get_pr_number() {
gh pr view --json=number --jq='.number'
}
alias prr-get='prr get "$(get_project)"/"$(get_pr_number)"'
alias prr-submit='prr submit "$(get_project)"/"$(get_pr_number)"'
alias prr-edit='$EDITOR ~/.local/share/prr/$(get_project)/$(get_pr_number).prr'
function prr-review() {
gh pr checkout "$1"
prr-get
prr-edit
}