commit 3afcfe508f7eed68ffcd3f2d6726e1aa486dafc7 parent 5289796e4611d478733b5f0066ecf31f32dc4c91 Author: Jacob R. Edwards <jacobouno@protonmail.com> Date: Sat, 16 Oct 2021 00:51:05 -0700 Add script to clean names making them easier to type Diffstat:
| A | local/bin/bin/cleanpath | | | 18 | ++++++++++++++++++ |
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/local/bin/bin/cleanpath b/local/bin/bin/cleanpath @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# cleanpath - Process names to make them easier to type +# [cleanname, the perfect name, is taken by plan9] +# +# 1. Insert separators between camel-case words +# 2. Replace most punctuation with space (including all but the last period) +# 3. Replace space with hyphen +# 4. Replace excess hyphens with nothing +# 5. Replace upper-case letters with their lower-case equivilents + +sed -E 's/([^A-Z])([A-Z][^A-Z])/\1 \2/g +s/[!"#$%&'\''()+,:;<>@[\\\]^{|}~]/ /g +s/\.([^.]*\.)/-\1/g +y/ /--/ +s/--+/-/g +s!(^|[/.])-!\1!g +s!-([/.]|$)!\1!g' | tr '[:upper:]' '[:lower:]'