A simple CLI URL shortener using s.lain.la API, with optional clipboard copy.
Project description
lain-shorten
A simple CLI URL shortener using s.lain.la API, with optional clipboard copy.
Installation
Via PyPI (Recommended)
You have the option to choose between the standard version (lain-shorten) or the desktop version (lain-shorten[clipboard]), which adds clipboard support for auto-copying links.
[!NOTE] For brevity, the examples below use the desktop version.
With pip (Basic)
pip install "lain-shorten[clipboard]"
With pipx (Isolated)
pipx install "lain-shorten[clipboard]"
With uv (Best)
The most efficient way to install or run the shortener.
# Permanent isolated installation
uv tool install "lain-shorten[clipboard]"
# Run once without installing
uvx --with "lain-shorten[clipboard]" lain-shorten <url1> <url2> <url3>
# Run in scripts or ad-hoc environments
uv run --with "lain-shorten[clipboard]" lain-shorten <url1> <url2> <url3>
From Source (Development)
# Clone the repository and navigate to it
git clone git@github.com:NecRaul/lain-shorten.git
cd lain-shorten
# Install environment and all development dependencies (mandatory and optional)
uv sync --dev
# Install pre-commit hook
uv run pre-commit install
# Optional: Run all linters and type checkers manually
uv run pre-commit run --all-files
# Run the local version
uv run lain-shorten <url1> <url2> <url3>
# Run tests
uv run pytest tests
Usage
Simply provide a URL, and the tool will automatically handle protocol validation and formatting.
Use --open to open each generated short URL in your default browser right after shortening. This makes it easy to verify each format resolves as expected in a real browser session.
# Shorten a URL
lain-shorten https://kuroneko.dev
# Protocol-less (automatically prepends http://)
lain-shorten kuroneko.dev
# irc
lain-shorten irc://irc.libera.chat/#archlinux
# ssh
lain-shorten ssh://necraul@kuroneko.dev
# mailto
lain-shorten mailto:necraul@kuroneko.dev
# sms
lain-shorten sms:+15551234567
# magnet torrent
lain-shorten "magnet:?xt=urn:btih:0123456789abcdef0123456789abcdef01234567&dn=Example"
# Open shortened URLs using the default browser
lain-shorten --open \
http://kuroneko.dev \
ircs://irc.libera.chat:6697/#archlinux \
xmpp:necraul@kuroneko.dev \
tel:+15551234567
# Display help and version
lain-upload -h
lain-upload -v
Supported Schemes
http://andhttps://links- protocol-less domains (automatically normalized to
http://) irc://andircs://linksssh://linksmailto://andxmpp://linkssms://andtel://linksmagnet:torrent links
Dependencies
- requests: send the API request for shortening.
Optional
- pyperclip: copy the shortened URLs to the clipboard.
How it works
The s.lain.la service allows shortening URLs via a POST request.
This tool automates the process to avoid typing long curl strings.
The Manual Way
curl -d "url=https://kuroneko.dev" https://s.lain.la
The lain-shorten way
- Batch Processing: Shorten multiple URLs in a single command execution, saving time over individual manual requests.
- Validation: Uses
urllibto ensure the URL is formatted correctly. - API Request: Sends the
POSTrequest viarequests. - Normalization: Automatically adds
http://if missing. - Clipboard (Optional): If
pyperclipis installed, the result is instantly copied to your clipboard.
Special thanks
- To 7666 of https://lain.la/ for running the shortener service that inspired this project.
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 lain_shorten-1.18.tar.gz.
File metadata
- Download URL: lain_shorten-1.18.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9acaae6e1077263c3dc71bb1338c9c7b090182fc6f005f7ea67123c8c86280e7
|
|
| MD5 |
a9ffe44ca6305f424d999dff6b6d9705
|
|
| BLAKE2b-256 |
ccd487ea74f5b4e9fd2c1117ff7c4a7e540bedc0a4993f66d6abea50b3efc72b
|
File details
Details for the file lain_shorten-1.18-py3-none-any.whl.
File metadata
- Download URL: lain_shorten-1.18-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b26c033269f2f5cd93fd880f8c2693158db36290b708db466aaa0235fa07a0b
|
|
| MD5 |
b3cdd323a3d73f7c28dc738e0bb6bc8d
|
|
| BLAKE2b-256 |
4f72474c475e0ace35b246dc937d67168f691658936ea99ebb68302b1d294fc4
|