Skip to content

[Feature/Enhancement Request] Support browsing/viewing files & line numbers/ranges #980

@pbnj

Description

@pbnj

The current git-browse script support opening the current git repo website of a given remote (default is origin) in the browser.

It would be a great addition if the script also supported opening the current git repo website at a specific file and line number(s).

Using current repo as an example:

# same behavior as today
$ git browse
# opens https://github.com/pbnj/git-extras (my origin remote url)

# open repo of a given remote
$ git browse upstream
# opens https://github.com/tj/git-extras

# open repo at file of current branch of a given remote
$ git browse origin bin/git-browse
# opens https://github.com/pbnj/git-extras/blob/master/bin/git-browse

# open repo at file & line number of current branch of a given remote
$ git browse origin bin/git-browse 42
# opens https://github.com/pbnj/git-extras/blob/master/bin/git-browse#L42

# open repo at file & line range of current branch of a given remote
$ git browse origin bin/git-browse 1 42
# opens https://github.com/pbnj/git-extras/blob/master/bin/git-browse#L1-L42

Here is how I accomplished this in another bash script: https://github.com/pbnj/dotfiles/blob/f544dadf8833d6687ac5d8dfc14c59d5890498a7/git/bin/git-browse

If there is agreement that we want this feature, I can port it over and submit a PR.

I imagine the challenge/complexity mostly being around how (if at all) we can make this logic as agnostic as possible so as to not have to maintain platform-specific logic for each one out there (e.g. github, gitlab, bitbucket, sr.ht, gitee, gitea, ...etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions