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:
parent
debce210d5
commit
835d695ed0
1 changed files with 22 additions and 0 deletions
22
site-modules/core/files/oh-my-zsh/custom/prr.zsh
Normal file
22
site-modules/core/files/oh-my-zsh/custom/prr.zsh
Normal 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
|
||||
}
|
||||
Loading…
Reference in a new issue