blob: 3ba5c6e577d7ff73ec013d4d787667bc4b108579 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/bin/zsh
# Light version of getKebabCase which skips out on
# a bunch of things we have no idea how to code with
# sed regex, but aren't all too important for utility use.
cat /dev/stdin | tr '[:upper:]' '[:lower:]' | sed \
-r \
-e 's/ /-/g' \
-e 's/&/-and-/g' \
-e 's/\+/-plus-/g' \
-e 's/%/-percent-/g' \
-e 's/(\b[^\s.-]{2,})\./$1-/g' \
-e 's/\.([^\s.-]{2,})\b/-$1/g' \
-e 's/[/@#$%*()_=,[\]{}|\\;:<>?`~]/-/g' \
-e 's/[áâäàå]/a/g' \
-e 's/[çč]/c/g' \
-e 's/[éêëè]/e/g' \
-e 's/[íîïì]/i/g' \
-e 's/[óôöò]/o/g' \
-e 's/[úûüù]/u/g' \
-e 's/[^a-z0-9-]//g' \
-e 's/-{2,}/-/g' \
-e 's/^-+|-+$//g'
|