Skip to content

Instantly share code, notes, and snippets.

@scmx
Created October 1, 2018 10:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scmx/6435f174323ecfc3937c99d939389064 to your computer and use it in GitHub Desktop.
Save scmx/6435f174323ecfc3937c99d939389064 to your computer and use it in GitHub Desktop.
How to abbreviate long tech words nicely #abbreviate #tech #i18n #l10n #k8s

How to abbreviate long tech words nicely :trollface:

Just for fun, I do not recommend using this

Ever heard of I18n? Probably. But do you know what it stands for? Internationalization. There's a few other common ones as well

  • l10n localization
  • k8s kubernetes

Okay, so now you too want to use it everywhere, obviously. Here's a script that abbreviates its input. (each word).

~/.bin/abbrev

#!/usr/bin/env ruby

abbrev_words = ARGV.to_a.map do |input|
  left, *mid, right = input.split("")

  "#{left}#{mid.size}#{right}"
end

puts abbrev_words.join(" ")

Examples

❯❯❯ abbrev Internationalization
I18n

❯❯❯ abbrev localization
l10n

❯❯❯ abbrev translation
t9n

❯❯❯ abbrev kubernetes
k8s

❯❯❯ abbrev Github
G4b

Contribed use case example :trollface:

A colleague ran into an issue where we had too long cron syslog ids with Nanobox. Couldn't be more than 15 characters 🙀.

Here's my joke suggestion for how to make it shorter.

❯❯❯ abbrev remind inactive users
r4d i6e u3s

❯❯❯ abbrev delete inactive users
d4e i6e u3s

❯❯❯ abbrev Import arbetsformedlingen ads
I4t a16n a1s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment