2024-08-12 21:13:47 +03:00
2024-08-12 21:13:47 +03:00
2024-08-12 21:13:47 +03:00
2024-08-12 21:13:47 +03:00
2024-08-14 00:36:33 +03:00
2024-08-13 21:29:07 +03:00
2024-08-12 21:13:47 +03:00

git-open

git-open is a git alias which lets you open various repository URLs in a project in your default browser. It makes it easy to find a project, a specific commit, a branch or PR on GitHub, GitLab and Bitbucket.

For example:

git open repo # open project main URL
git open prs # open PRs/MRs list
git open branch # open current branch URL
git open branch some/branch # open specific branch
git open commit # open current commit URL
git open commit abc123 # open specific commit URL
git open file .gitignore # open specific file URL

You can always use git open without arguments to see the list of possible options:

git open

Usage: git open <command>
Commands:
  project|repo|open|.       Open the project
  branch                    Open the project at given (or current) branch
  commit                    Open the project at given (or current) commit
  file                      Open the project at given file. Can also append ref hash
  prs                       Open the PR list
  pr                        Open a new PR
  actions|pipelines|ci      Open the CI/CD pipelines

Installation

There are several methods to install git-open:

Manually

  1. Clone the git repository:

    cd $installpath
    git clone https://github.com/chenasraf/git-open.git
    
  2. Load the entry file somewhere in your init (such as ~/.zshrc):

    source /path/to/git-open/git-open.plugin.zsh
    

    Alternatively, you can add the following value to your git config to load manually:

    git config --global alias.open "!/path/to/git-open/git-open.zsh open"
    

Zplug

zplug "chenasraf/git-open"

Adding to LazyGit

You can add git-open to your lazygit config file and open selected files/refs with it. Here is an example customCommands entry, but you can of course modify it or create your own:

customCommands:
  - key: 'B'
    context: 'global'
    prompts:
      - type: 'menu'
        title: 'Choose an action'
        key: 'action'
        options:
          - name: 'Open Branch'
            value: 'branch'
          - name: 'Open Default Branch'
            value: 'project'
          - name: 'Open Commit'
            value: 'commit'
          - name: 'Open File'
            value: 'file'
          - name: 'Create Pull Request'
            value: 'pr'
          - name: 'Open Pull Requests'
            value: 'prs'
          - name: 'Open CI/Actions'
            value: 'ci'
    # pass selected contexts to `git open`, prefer file, then remote branch, then local branch
    command: 'git open {{.Form.action}} {{if .SelectedFile}}{{.SelectedFile.Name | quote}}{{else if .SelectedRemoteBranch}}{{.SelectedRemoteBranch.Name | quote}}{{else if .SelectedLocalBranch}}{{.SelectedLocalBranch.Name | quote}}{{end}}'
    loadingText: 'Opening...'

Contributing

I am developing this package on my free time, so any support, whether code, issues, or just stars is very helpful to sustaining its life. If you are feeling incredibly generous and would like to donate just a small amount to help sustain this project, I would be very very thankful!

Buy Me a Coffee at ko-fi.com

I welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature, don't hesitate to open an appropriate issue and I will do my best to reply promptly.

Description
Git aliases for opening project, branch, commit, PRs, etc from CLI
Readme MIT 92 KiB
Languages
Shell 93.4%
Makefile 6.6%