Skip to content

Instantly share code, notes, and snippets.

@GennadySpb
Created February 13, 2020 07:57
Show Gist options
  • Save GennadySpb/c5a26fa808e9d9dbb25e4321d4ec980d to your computer and use it in GitHub Desktop.
Save GennadySpb/c5a26fa808e9d9dbb25e4321d4ec980d to your computer and use it in GitHub Desktop.
# create URL friendly name from arbitrary string, cut length to 63 chars
# like CI_COMMIT_REF_SLUG in Gitlab
slugify() {
echo -n "$1" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z | cut -c -63
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment