get-codeshare
v0.1.3
Published
A CLI to instantly share links to specific lines of code.
Downloads
18
Readme
CodeShare CLI
Instantly share code from your terminal. The missing link for your code.
This is the official command-line interface for the CodeShare suite. It allows you to generate universal, shareable links to specific lines of code directly from your terminal, without ever leaving your workflow.
The generated links are smart: they open in VS Code for teammates who have the CodeShare extension and fall back to a beautiful, read-only web view for everyone else.
Features
- Blazing Fast: Create links to code selections in seconds.
- Git-Aware: Automatically detects your Git repository, branch, and remote to create permanent, context-rich links.
- Stateless Fallback: Works even outside of a Git repository by creating temporary, shareable snippet links.
- Cross-Platform: Works on macOS, Windows (WSL, Git Bash), and Linux.
- Clipboard Integration: Automatically copies the generated link to your clipboard.
Installation
To install the CodeShare CLI, you need to have Node.js and npm installed.
Install the package globally using npm:
npm install -g get-codeshareThis will make the codeshare command available in your system's PATH.
Usage
The command's syntax is simple:
codeshare path/to/your/file.js:lineExamples
1. Sharing a Single Line
This command will generate a link to line 42 of src/server.ts.
codeshare src/server.ts:422. Sharing a Range of Lines
To share a range of lines (e.g., from line 10 to 25), use a hyphen.
codeshare src/app.js:10-25How It Works: Two Powerful Modes
The CodeShare CLI automatically adapts to your context.
Mode 1: Git-Aware Link (In a Git Repository)
If the file you're sharing is part of a Git repository with a remote origin or upstream, the CLI will generate a permanent, context-aware link.
Example Output (Git-Aware):
✅ Link (Git-aware) copied to clipboard!
https://codeshare.sarthaks.tech/l/aHR0.../bWFpbg==/c3JjL2FwcC5qcw==/10-25This link contains the encoded Git remote URL, branch name, file path, and line range.
Mode 2: Stateless Snippet Link (Outside a Git Repository)
If you use the CLI on a file that isn't tracked by Git, or in a directory that isn't a Git repository, it will automatically create a temporary snippet link.
Example Output (Stateless Snippet):
Not a Git repository. Creating a shareable snippet link...
✅ Snippet link copied to clipboard!
https://codeshare.sarthaks.tech/s/yCw8_SoCThis link points to a temporary, anonymous snippet that will expire after 24 hours.
Contributing
This project is open source and part of the CodeShare suite. Contributions are welcome! Please feel free to open an issue or submit a pull request on the main CodeShare Project Repository.
License
This project is licensed under the MIT License.
