<commit_before>zsh-open-github-pr [![Build Status](https://travis-ci.org/caarlos0/zsh-open-github-pr.svg?branch=master)](https://travis-ci.org/caarlos0/zsh-open-github-pr)
==================

zsh open a github pull request from command line.

## Install using antigen

```sh
antigen bundle caarlos0/zsh-open-github-pr
```

## Usage

```sh
git checkout -b random-feature
// do some stuff
git commit -am 'did some stuff'
git push
open-pr
```

This will open an URL like
`https://github.com/origin/repo/compare/master...random-feature`.

This will open your browser (using `open` on OSX and `xdg-open` on Linux) in
a URL to create a Pull Request from your current branch to `upstream` or
`origin` (if there is no `upstream` remote) `master` branch.

In the case you have a `upstream` remote (you are working on a fork), the
previous example will open an URL like

You can also specify another branch, like
`https://github.com/upstream/repo/compare/master...origin:random-feature`

```sh
open-pr experimental
```

This will open an URL like
`https://github.com/origin/repo/compare/random-feature...experimental`. It will
also deal with forks.<commit_msg>A better readme :beer:<commit_after>zsh-open-pr [![Build Status](https://travis-ci.org/caarlos0/zsh-open-pr.svg?branch=master)](https://travis-ci.org/caarlos0/zsh-open-pr)
==================

ZSH plugin to open pull requests from command line.

## What it does

Basically, when you call `open-pr`, the function will verify if you are working
on a fork (by convention, you have an `upstream` remote), then, it will open
your browser in the correct URL so you can just hit the `Create Pull Request`
button.

The function also accepts one argument, in case you want to specify another
target branch (instead of master, which is the convention).

URL breakdown:

```
https://github.com/target-remote/repo/compare/master...origin:random-feature
          |           |            |    |        |   |    |     |
          |           |            |    |        |   |    |      -> the branch
          |           |            |    |        |   |    |         you want
          |           |            |    |        |   |    |         to submit
          |           |            |    |        |   |    |
          |           |            |    |        |   |     -> will appear only
          |           |            |    |        |   |        if you are
          |           |            |    |        |   |        working in a fork
          |           |            |    |        |   |
          |           |            |    |        |    -> default GitHub compare
          |           |            |    |        |       thing
          |           |            |    |        |
          |           |            |    |         -> target branch
          |           |            |    |
          |           |            |     -> default GitHub endpoint to open a PR
          |           |            |
          |           |             -> the target repository, also from origin
          |           |                or upstream remotes
          |           |
          |            -> can be both origin or upstream
          |
           -> default host
```

## Usage

For example, when you work on your own project:

```sh
$ git remote -v
origin  <EMAIL>:caarlos0/zsh-open-pr.git (fetch)
origin  <EMAIL>:caarlos0/zsh-open-pr.git (push)

$ git branch
* master

$ git checkout -b random-feature
$ touch this-file-is-important
$ git add -A
$ git commit -m 'did some stuff'
$ git push
$ open-pr
# will browse https://github.com/caarlos0/zsh-open-pr/compare/master...random-feature
```

Working on a fork:

```sh
$ git remote -v
origin  <EMAIL>:random-user/zsh-open-pr.git (fetch)
origin  <EMAIL>:random-user/zsh-open-pr.git (push)
upstream  <EMAIL>:caarlos0/zsh-open-pr.git (fetch)
upstream  <EMAIL>:caarlos0/zsh-open-pr.git (push)

$ git branch
* master

$ git checkout -b random-feature
$ touch this-file-is-important
$ git add -A
$ git commit -m 'did some stuff'
$ git push
$ open-pr
# will browse https://github.com/caarlos0/zsh-open-pr/compare/master...random-user:random-feature
```

Previous example, but to a `develop` branch, for instance:

```sh
$ open-pr develop
# will browse https://github.com/caarlos0/zsh-open-pr/compare/develop...random-user:random-feature
```

## Install using antigen

```sh
$ antigen bundle caarlos0/zsh-open-pr
```

And hit `open-pr` on your repositories.

You can also alias it:

```sh
$ git config --global alias.pr '!zsh -ic git-open-pr'
$ git pr
```
{'fraction_non_alphanumeric': 0.12837986370630908, 'fraction_numerical': 0.002857770938667839, 'mean_word_length': 1.7811735941320292, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3764340', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1364, 'n_words': 389}