#!/bin/sh # slugify — convert text to url-safe slugs if [ -z "$1" ]; then read -r input else input="$*" fi printf '%s' "$input" \ | tr '[:upper:]' '[:lower:]' \ | sed 's/[^a-z0-9 _-]//g' \ | tr ' _' '--' \ | sed 's/--*/-/g; s/^-//; s/-$//'