A CLI tool to run Python scripts directly from GitHub URLs
Project description
Githrun
Githrun is a versatile command-line tool and VS Code extension that enables you to execute, explore, and install Python scripts directly from GitHub and Gists. It streamlines remote execution by handling dependencies, private repositories, and local tool installation.
VS Code Extension
Extension Installation & Setup
1. Install the Extension
- Marketplace: Search for "Githrun" in the VS Code Extensions view and click Install.
- Manual: If installing from a VSIX file, go to Extensions -> ... -> Install from VSIX.
2. Install the Core CLI (Required)
This extension acts as a bridge to the Githrun command-line tool. You must have the Githrun CLI installed on your system.
Open your terminal and run:
pip install githrun
Extension Features & Usage
CodeLens Integration
The extension automatically scans Markdown, Python, and Text files for GitHub or Gist URLs.
- Action: Look for the "Run with Githrun" link appearing above any detected URL.
- Click: Clicking the link opens a terminal and executes the script immediately.
Context Menu
- Action: Highlight any GitHub URL in your editor.
- Click: Right-click the selection and choose Githrun: Run Selected Text.
Command Palette
- Action: Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac). - Command: Type
Githrun: Run from URL...and paste your target link into the input box.
Extension Settings
The extension attempts to automatically detect your Githrun installation.
- It first checks for
githrunin your global PATH. - If not found, it tries
python -m githrun(orpython3on Mac/Linux).
Features
- Remote Execution: Run scripts from GitHub or Gist URLs instantly.
- Auto-Dependency Management: Automatically creates temporary virtual environments and installs missing packages using the
--auto-installflag. - Private Repo Access: Authenticate securely with GitHub tokens to access private code and increase API rate limits.
- Bookmarks: Save long URLs as short aliases (e.g.,
githrun run clean-db). - Tool Installation: Install remote scripts as permanent local CLI commands available in your system path.
- Recursive Downloads: Download entire folders or specific sub-directories from a repository.
- Interactive Search: Search for files in a repo and run them immediately from the results.
- Smart Caching: Caches API responses to speed up repeated searches and reduce API usage.
CLI Usage
1. Run Remote Code
Execute a script directly from a URL.
Basic Execution:
githrun run [https://github.com/user/repo/blob/main/script.py](https://github.com/user/repo/blob/main/script.py)
Run Gists:
githrun run [https://gist.github.com/user/1234567890abcdef](https://gist.github.com/user/1234567890abcdef)
Auto-Install Dependencies: If a remote script requires packages you do not have installed (e.g., pandas, requests), use this flag to run it in an isolated environment:
githrun run [https://github.com/user/repo/blob/main/data.py](https://github.com/user/repo/blob/main/data.py) --auto-install
Inspect Code: View the source code with syntax highlighting before running it (Safety Check):
githrun run [https://github.com/user/repo/blob/main/script.py](https://github.com/user/repo/blob/main/script.py) --inspect
2. Authentication (Private Repos & Rate Limits)
GitHub limits unauthenticated requests to 60 per hour. Login to increase this limit to 5,000 and access private repositories.
githrun login ghp_YourPersonalAccessToken...
The token is stored securely in ~/.githrun/config.json.
3. Bookmarks
Stop copy-pasting long URLs. Save them once, run them anywhere.
Add a Bookmark:
githrun bookmark add clean-db [https://github.com/user/repo/blob/main/utils/cleanup.py](https://github.com/user/repo/blob/main/utils/cleanup.py)
Run a Bookmark:
githrun run clean-db
List Bookmarks:
githrun bookmark list
4. Install as a Tool
Turn a remote Python script into a command you can run from anywhere in your terminal.
githrun install [https://github.com/user/repo/blob/main/my-tool.py](https://github.com/user/repo/blob/main/my-tool.py) --name mytool
- Windows: Creates a
.batfile in~/.githrun/bin. - Linux/Mac: Creates an executable shim in
~/.githrun/bin. - Note: You must add
~/.githrun/binto your system PATH.
5. Find & Search
Search for files inside a remote repository without cloning it.
# Search for files containing "config"
githrun find [https://github.com/user/repo](https://github.com/user/repo) "config"
This command is interactive. You can select a result number to run it immediately.
6. Download Files & Folders
Download artifacts to your local machine.
Download a single file:
githrun download [https://github.com/user/repo/blob/main/script.py](https://github.com/user/repo/blob/main/script.py)
Download a specific folder (Recursive):
githrun download [https://github.com/user/repo/tree/main/src/utils](https://github.com/user/repo/tree/main/src/utils) --output ./local_utils
7. Show Folder Contents
List files in a remote directory to understand the structure.
githrun show [https://github.com/user/repo/tree/main/src](https://github.com/user/repo/tree/main/src)
Python API Usage
You can use Githrun inside your own Python scripts.
import githrun
# 1. Search a repository
results = githrun.search_repository("[https://github.com/user/repo](https://github.com/user/repo)", "test")
for item in results:
print(item['path'], item['raw_url'])
# 2. Download a file
githrun.download_file("[https://github.com/user/repo/blob/main/script.py](https://github.com/user/repo/blob/main/script.py)", output_path="script.py")
# 3. Download a full folder
githrun.download_folder("[https://github.com/user/repo/tree/main/src](https://github.com/user/repo/tree/main/src)")
# 4. Execute code programmatically
exit_code = githrun.execute_remote_code("[https://github.com/user/repo/blob/main/script.py](https://github.com/user/repo/blob/main/script.py)", args=["--verbose"])
Configuration
Githrun stores configuration and cache files in your home directory:
- Config:
~/.githrun/config.json(Tokens, Bookmarks) - Cache:
~/.githrun/cache/(API responses) - Binaries:
~/.githrun/bin/(Installed tools)
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file githrun-0.1.2.tar.gz.
File metadata
- Download URL: githrun-0.1.2.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7eed57910e21635191fc7175dbe471171a5d460d6a2897e6a1cee8ab3cef71d
|
|
| MD5 |
28ea89d716681fa0fa2ee782951507db
|
|
| BLAKE2b-256 |
b123735975eab4e62549037c9202dfdcf9b54287f2bf57127e3ed25dbcb60ce8
|
File details
Details for the file githrun-0.1.2-py3-none-any.whl.
File metadata
- Download URL: githrun-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e8e043c4cff4a57c3977d754bb4877e03cf73e23da41c62a8f79ab243005327
|
|
| MD5 |
fe2bd9e375d42bda719676dc0a2752fc
|
|
| BLAKE2b-256 |
82f4c2d4ca538fd79c0904c665f5fe426cc3277b6eec3563eec682244c74e90b
|