Skip to content

A collection of CLI tools to operate frequently needed text transformations

Notifications You must be signed in to change notification settings

maxlath/text-transform-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

text-transform-cli

A collection of CLI commands to operate frequently needed text transformations

For those who have to pass from camel to snake case 10+ times a day, and all this kind of small text operation that makes a developer's daily routine. (Note that, for the most frequent case conversions, there is probably a plugin to do that directly from your text editor)

Quick examples:

# Transforming text passed as arguments
snake myNewFunctionName
# => outputs 'my_new_function_name' and copy it to your clipboard

# Transforming text passed on stdin
cat somefile | uppercase > somefile_uppercased

Summary

Installation

npm install -g text-transform-cli

⚠️ this will add several un-namespaced new commands to your PATH, some would consider it "polluting", but using those 10+ times a day, I consider that it's totally worth it. But that's just my use case.

Commands

Case manipulation

camel

camel helloWorld_What is happening-Today
# => helloWorldWhatIsHappeningToday

pascal

pascal helloWorld_What is happening-Today
# => HelloWorldWhatIsHappeningToday

kebab

kebab helloWorld_What is happening-Today
# => hello-world-what-is-happening-today

snake

snake helloWorld_What is happening-Today
# => hello_world_what_is_happening_today

colon

colon helloWorld_What is happening-Today
# => hello:world:what:is:happening:today

capitalize

capitalize helloWorld_What is happening-Today
# => Helloworld_what is happening-today

startcase

startcase helloWorld_What is happening-Today
# => Hello World What Is Happening Today

lowercase

lowercase helloWorld_What is happening-Today
# => hello world what is happening today

uppercase

uppercase helloWorld_What is happening-Today
# => HELLO WORLD WHAT IS HAPPENING TODAY

randomcase

randomcase helloWorld_What is happening-Today
# => hElloWorlD_WHaT Is HAppEniNG-tOdAy

Script level

superscript

superscript hello 12(3)4=5
# => ʰᵉˡˡᵒ ¹²⁽³⁾⁴⁼⁵
printf '5.123*10' ; superscript 5 --no-cb
# => 5.123*10⁵%

NBSome characters won't be converted as they aren't defined in Unicode

subscript

subscript hello 12(3)4=5
# => ₕₑₗₗₒ ₁₂₍₃₎₄₌₅
printf 'H' ; subscript 2 --no-cb ; printf 'O'
# => H₂O

NB: Some characters won't be converted as they aren't defined in Unicode

Encoding

urlencode

urlencode https://en.wikipedia.org/wiki/Minister_for_Māori_Development
# => https://en.wikipedia.org/wiki/Minister_for_M%C4%81ori_Development
urlencode --component https://en.wikipedia.org/wiki/Minister_for_Māori_Development
# => https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMinister_for_M%C4%81ori_Development

urldecode

urldecode https%3A%2F%2Finventaire.io%2Fentity%2Fwd%3AQ315910
# => https://inventaire.io/entity/wd:Q315910

htmlencode

htmlencode "'HMAC-SHA256' & 'HMAC-SHA1'"
# => 'HMAC-SHA256' & 'HMAC-SHA1'

htmldecode

htmldecode ''HMAC-SHA256' & 'HMAC-SHA1''
# => 'HMAC-SHA256' & 'HMAC-SHA1'

unicode

Get the UTF-16 codes for a given string

unicode 'zàéä'
# => \u007a\u00e0\u00e9\u00e4

Style

boldsans

boldsans yolo
# => 𝘆𝗼𝗹𝗼

boldserif

boldserif yolo
# => 𝐲𝐨𝐥𝐨

bolditalicsans

bolditalicsans yolo
# => 𝙮𝙤𝙡𝙤

bolditalicserif

bolditalicserif yolo
# => 𝒚𝒐𝒍𝒐

gothic

gothic yolo
# => 𝔶𝔬𝔩𝔬

gothicbold

gothicbold yolo
# => 𝖞𝖔𝖑𝖔

italicsans

italicsans yolo
# => 𝘺𝘰𝘭𝘰

italicserif

italicserif yolo
# => 𝑦𝑜𝑙𝑜

monospace

monospace yolo
# => 𝚢𝚘𝚕𝚘

strike

strike yolo
# => ̶y̶o̶l̶o
strike --tild yolo
# => ̴y̴o̴l̴o
strike --short yolo
# => ̵y̵o̵l̵o
strike --long yolo
# => ̶y̶o̶l̶o
strike --slash yolo
# => ̷y̷o̷l̷o
strike --slashShort yolo
# => ̸y̸o̸l̸o

underline

underline yolo
# => ̲y̲o̲l̲o
underline --dashed yolo
# => y̱o̱ḻo̱
underline --double yolo
# => ̳y̳o̳l̳o

upsidedown

upsidedown yolo
# => ʎoןo

Misc

length

length gloubiboulga
# => 12

reverse

reverse hello
# => olleh
reverse hello world
# => dlrow olleh

reversewords

reversewords hello
# => hello
reversewords hello world
# => world hello

zalgo

zalgo Lorem ipsum dolor sit amet

L̶̨̫̙͕͈͖͖̱̰̼̠͑̋̾ͯ̈̅ͤ͆͛̐́o̴̘͖̣̝̟͙̰̰̥͍͋̃ͣͤͯ̿͊̓̃̏̀͢r̜̥͔̺̩͔̖̣͙ͥ͌̾̉̽̈́̿ͧ̅͞ͅ ҉͢ę̨̢̯̖̺̣̜̻̳̘͍̐̅͌ͥͯ͂̔ͯͭ͊ͅm̹͓̺̼̗͉̟̙͚̙͑͐́ͯ͗͗́̔͐̉ ҉̴͡ ̵͚̙̩̬̫͉̼̻̤̯ͤ́͋͂̃̉̓̒ͦ̀̕͝i̡̛̤̩̦̱͖̻̥̫͍ͦ̓͋̿̊̑͒̔ͫ̎̀ͅp̛̞̮̪̩͖͖̳̪̜͔̀̉ͪ̑̄̇́̾̽̒͘͠s͍͙̭͕̹̜̤̣͕̺̐̊ͥ̉ͥ̈ͩ̅̉̀͝͞͠ṷ̸̶̺̦̝̺͇͎̘̙̮̂ͤͬͩ̄̈ͫ̓̐ͥ̕m̵̩̮̖͎͕͈̯͕͍̟̌ͨ͌̉̽͂̂̈̇̚͜͠ ̶̗̙̦͉̺̺̫͕͖̮̆ͤ͊̽̅͋ͫͫ̓̚͢͞d̛̰͓̘̣̹̪̤̥̥͔ͩ̊̇̒ͧ̔ͦͪͦͭ͞͞ǫ̷̯̟̼̼̯̯̲̪͕͉̀̇́̃ͩͤͮ̇͑ͭ͝ļ̵̹̫̱͕̯͙̠͇̱̜̎̽ͫ͐̇̿̃ͭͪͬ͠o̶̷̼̼͓̜̣̥̪͈͉̝͑ͫ̋̑̊͑̒͒ͫ̎́ŗ̥̬̝̝͍̱̲̲̙̅̽ͫͨ̃ͩ̓̋ͤ̋͘͜ͅ ̨̻͕̳͍̝̟͚͖͖̱͐̍̄͌̑̍͆͛̄̚͢͝ș̵̨̛͕̦̙̗̖̬̱͉͎͗̐͑̓ͤ̏ͨ̍͊̿i̧̛̞̼̯̻̤̖̜̙̹̺ͦ̌ͭͧ̄́̾͐̓̚͠t̷̘̭̬͇͓̯̮̗̹̞̐ͥ̋̑̏͒̏̌͑̎͘͘ ̷̠̗̹̝͈͍̰̱͚͇̓̂ͫͣ̾̿̂ͦ́ͧ͠ ҉a̴̸̶͚͓͉̟͕̳͓̞̫͈ͥ̑̓ͭͤ̐̿̿̉̚m͎̰͖̞̘͓̪̲̲̻̽̌̒͑ͣ͒̎̈̐̎̀͠͡ę̨̹̮̼͙̩̭͎͈͓̬͛ͭͣ̋ͣ̈ͪ̔ͥ̂͝t͖̠̭͍̞̖̤͇̩̘͋ͯ̽̌͑ͪ̂ͫ͋ͫ͜͝ ҉

size

Size options: min, medium, max (Default: medium)

zalgo --min Lorem ipsum dolor sit amet

L̜̰̟̄͆̒́o̹̝̥͛̒͌͜r̨̺͕̮ͤ́̓e̖͕̾̂̄́ͅm̴͓͍̑͛̑ͅ ̢̠̘̥̑ͤ̽i̢͈̩̔̿͐ͅp̛̹̮̖̿ͭͬs̺̜̠ͪ̾̇͠u͙̖̦ͦͪͮ͠m̛͇̠̮ͥͯ̎ ͙̞̯̅̄͋ ҉d̳̳̙͐ͥ͐͠ő͉̟͈̉̓ ҉l̸͚̟̗ͧͨ͊o̷̦̪̎̎ͧͅȑ̭̪̫̉ͩ ҉ ̡͔̘̮ͨ̈̚s̨̗͚͉͗͋͑ì͓̺̯ͨͮ̀t̸͉̬͇ͨ̍̐ ̮̣͇̐͛ͣ͢a̵͎̻̳̍ͪ̎m̻̰̖ͫͮ̊ ҉e̷̘̞͖̽ͯ͐t̨͖͙͙̉ͯ̚

position

Position options: up, mid, down (Default: up, mid, and down)

zalgo --mid Lorem ipsum dolor sit amet

L̷͟͠ơ̵͟r ҉̕ ҉ę̸̨m̶̨͢ ̸̨̡i̴̸͠p̢̛͘ş̛̛ú͡͠m̵̡̕ ̨͘͟d̨̛͘o̢͘͞l̡̀͡o̸͢͟r̢͘͝ ̵̛͟s̴̸̴i̸̢̡t̵̴͠ ̷̨́ą̀̕ḿ̨͜e̢̨͡t̸̕͡

ease

Ease function options: linear, log, exp, cubic, bounce, elastic, random (Default: none)

zalgo --cubic Lorem ipsum dolor sit amet

Lorem ipsum̳̑ ̝ͥd̠͊ọ̒l̦̺̋̂o̪͓̎̋́r̥̬͂̌͘ ̞͕̣ͯ͆̈̀s̶̙̥̦ͨͤ͌i̜͖̠̦̊̊̍̀͝t͈̼̻͉̺͐ͪ͑ͬ̒͠ ̧̖̱̺̭̤̈̍̓͂̚͜ä̸̮̰̝̹̦͌̏ͧ̓ͩ͡ͅm̰͈̝̱̣̼͓̓͒͑͊̏ͤ̑͟͜e̞̰̭͉͉͙͕̤̓́̽ͮ̍̎́́̚̚ṭ̸̢͈̦̙̦͎͉̰͔͋̈̅̌ͬ̆ͩ͑ͩ ҉

Options

Global options available for all commands

Disable copy to clipboard

By default, the output is copied to the clipboard, but this can be disabled by passing the option command -n or --no-clipboard

# 'foo_bar' will be copied to your clipboard
snake fooBar
# disable that behaviour
snake fooBar --no-clipboard
# same but for the lazy
snake fooBar -n

Copying to the clipboard is automatically disabled in some cases:

# when arguments come from the process standard input
echo 'fooBar' | snake

# when the process standard output is redirected to a file or another process
snake 'fooBar' | grep 'foo'
snake 'fooBar' > somefile

See also

License

MIT

About

A collection of CLI tools to operate frequently needed text transformations

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published