Skip to content

cortex359/shlink-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

shlink-cli

A command-line interface for Shlink, the self-hosted URL shortener. Written in Bash with no dependencies beyond curl and jq.

Shlink ships with its own CLI, but that tool runs on the server itself and requires direct access to the Shlink installation. This project talks to Shlink's REST API instead, so you can manage your short URLs from any machine without SSH access or server-side tooling.

Installation

  1. Download the shlink script and make it executable:

    chmod +x shlink
  2. Place it somewhere in your $PATH (e.g. /usr/local/bin/ or ~/.local/bin/).

  3. Set the required environment variables:

    export SHLINK_API="https://s.example.com"
    export SHLINK_API_KEY="your-api-key"

    Optionally set the API version (defaults to 3):

    export SHLINK_API_VERSION=3

Shell Completions

Bash -- add to ~/.bashrc:

source /path/to/shlink-completion.bash

ZSH -- copy _shlink into your $fpath:

mkdir -p ~/.zsh/completions
cp _shlink ~/.zsh/completions/
# Add to ~/.zshrc:
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit

Both completions provide dynamic tag completion by querying your Shlink instance.

Dependencies

Usage

shlink --help
shlink 1.0.0 - CLI for Shlink URL shortener

Usage: shlink [-q|--quiet] [-j|--json] COMMAND [ARGS...]

Short URLs:
  list                  List short URLs
  create URL            Create a new short URL
  get CODE              Get short URL details
  edit CODE             Edit a short URL
  delete CODE           Delete a short URL

Tags:
  tags                  List all tags
  tag-stats             List tags with statistics
  tag-rename OLD NEW    Rename a tag
  tag-delete TAG...     Delete tags

Visits:
  visits                General visit statistics
  visits-url CODE       Visits for a short URL
  visits-tag TAG        Visits for a tag
  visits-domain DOMAIN  Visits for a domain
  visits-orphan         Orphan visits
  visits-delete-url     Delete visits for a short URL
  visits-delete-orphan  Delete all orphan visits

Domains:
  domains               List configured domains

Redirect Rules:
  redirect-rules CODE         List redirect rules
  redirect-rules-set CODE JSON  Set redirect rules

Other:
  api METHOD PATH [BODY]  Raw API call
  help [COMMAND]           Show help
  version                  Show version

Global Options:
  -q, --quiet           Minimal output (for scripting)
  -j, --json            Output raw JSON
  -h, --help            Show help

Environment Variables:
  SHLINK_API            Base URL of the Shlink instance
  SHLINK_API_KEY        API key for authentication
  SHLINK_API_VERSION    API version (default: 3)

Run 'shlink help COMMAND' for details on a specific command.

About

Bash client for the self-hosted URL shortener Shlink providing an CLI for the Shlink REST-API.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages