# Open Repo shell tool
> Open the current git repo directory on GitHub in your default browser.

Run this in a directory within a local git repo. The directory will be opened in your browser such as on GitHub.


## Features

- Works for any user or org, as long as `.git` directory exists at some level.
- Recognizes subdirectories.
- Handles branches.
- Supports any host - GitHub, BitBucket, GitLab, etc.
- Works with both SSH and HTTP remote urls .
    - `git@github.com:USERNAME/REPO_NAME.git`
    - `https://github.com/USERNAME/REPO_NAME.git`


## Sample

```console
$ open-repo
Opening: https://github.com/MichaelCurrin/unicron/tree/master
```


## Installation

1. Download or copy the contents of the script. You can omit `.sh` in the name - it just helps for syntax highlighting when viewed on GitHub.
1. Add as a shell script in `~/bin` directory or somewhere else in your PATH.
1. Mark it as executable.
  ```sh
  $ chmod +x open-repo
  ```
1. Navigate to a git directory and run the script as you named like.
  ```sh
  $ cd my-repo
  $ open-repo
  ```


## Usage

Here is a demo of running commands in the `MichaelCurrin/unicron` GitHub repo.

```sh
$ git clone git@github.com:MichaelCurrin/unicron.git
$ cd unicron
```

### Open root

```console
$ open-repo
Opening: https://github.com/MichaelCurrin/unicron/tree/master
```

### Open subdirectory

```console
$ cd docs
$ open-repo
Opening: https://github.com/MichaelCurrin/unicron/tree/master/docs/
```

### Switch branches

```console
$ git checkout my-feature
$ open-repo
Opening: https://github.com/MichaelCurrin/unicron/tree/my-feature/docs/
```