Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tfiers/githyperlink
Get a link to the web version of a git-tracked file or directory
https://github.com/tfiers/githyperlink
browser command-line-tool git github gitlab python-package url
Last synced: about 2 hours ago
JSON representation
Get a link to the web version of a git-tracked file or directory
- Host: GitHub
- URL: https://github.com/tfiers/githyperlink
- Owner: tfiers
- License: mit
- Created: 2022-03-03T14:53:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-04T17:15:05.000Z (almost 3 years ago)
- Last Synced: 2024-10-06T09:08:23.376Z (3 months ago)
- Topics: browser, command-line-tool, git, github, gitlab, python-package, url
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# githyperlink
Get a link to the web version of a git-tracked file or directory.
Applies to GitHub and GitLab remotes (and maybe others but those are not tested).
## Usage
```bash
$ gethyperlink [PATH]
```
(Note the spelling here: _get_ hyperlink).If `PATH` is not specified, a link for the current directory is given.
### Example
```bash
$ cd my-pretty-repo/subdir$ gethyperlink somefile.jl
https://github.com/yourname/my-pretty-repo/blob/main/subdir/somefile.jl
```You might want to define an alias, for example, in `~/.bashrc`:
```bash
alias gl="gethyperlink" # Or maybe 'gurl' (get url) 💅
```### Direct usage in Python
```py
from githyperlink import get_hyperlinkprint(get_hyperlink(__file__))
# → https://gitlab.com/you/my_scripts/blob/main/this_script.py
```
The argument to `get_hyperlink` can be a string, as above, or a `pathlib.Path`.## Installation
```
pip install githyperlink
```
This will get you the[![Latest release on PyPI](https://img.shields.io/pypi/v/githyperlink.svg?label=latest%20release%20on%20PyPI:)](https://pypi.python.org/pypi/githyperlink/),
and makes the command-line tool `gethyperlink` globally available.
To upgrade an existing installation to the version above, use `pip install -U githyperlink`.
Requires Python ≥ 3.9.
## Features
- `git` is called directly, in a subprocess: this is faster than the default usage of
`GitPython`, and spares a dependency. (Currently, we only depend on [`click`](https://click.palletsprojects.com/)).
- Not many features.
This makes the source code easier to grok, and easier to modify for your own purposes.