A simple command for converting and processing data from your clipboard.

Related tags

CLI Tools poly
Overview

Poly

A simple command for converting and processing data from your clipboard.

Installation

Unix-based Install Script

NOTE: NEVER BLINDLY RUN ANY SCRIPT THAT ASKS FOR sudo!
Please inspect the file first by viewing the raw file from the URL in the command below before piping it to /bin/bash.

The install script needs sudo for copying the script into /usr/bin and setting it to be executable.

sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/3digitdev/poly/master/install.sh)"

(requires sudo permission, also will prompt to install Python packages):

Windows Support [FUTURE]

This script is not designed to support Windows at this time.

Feel free to make a PR to add support and install instructions!

Usage

This script will expect you to have the text it will manipulate in your clipboard. When you run a command, it will do its job, and if it is successful, it will put the modified text back into your clipboard, as well as send it to stdout.

You can generally convert data with the following format:

poly [ options]

Any other generic command is simply

poly [ options]

You can find some basic help from the --help option at any level:

poly --help
poly json --help
poly yaml --help
...etc

Chat Copypasta

A slowly-expanding list of chat programs to copy/paste out of into a more sane a readable format (thanks, emoji reactions...)

The intention is for each command to support both the webapp and the desktop client for each of the chat programs (Yes, they copy differently. No, you shouldn't be surprised.)

Supported chat program(s):

  • Slack

Future support:

  • Discord
  • MS Teams

Conversions

All of the following formats convert between each other:

  • JSON
  • YAML
  • TOML
  • JWT
  • URL Query String (see below for what this means)

NOTE: Some data types (like null in TOML) won't convert and might be dropped!

Additionally, you can convert between color formats:

  • Hex (e.g. #123, #123456, #1234, #12345678)
  • RGB (e.g. (10, 10, 10), (5,5,5))
  • RGBA (e.g. (10, 10, 10, 10), (5,5,5,5))

JWT Conversion

Converting to JWT requires two additional options:

  • -s, --secret: A secret string to encode/decode with
  • -a, --algorithm: An algorithm to encode/decode with

URL Query String Type Conversion

When converting from a query string you can use the -c, --convert flag to tell poly to attempt to convert all the values in the query string. They all start as strings, but it will attempt to do things like convert "true" to true for JSON/YAML, etc. This only works for the basic data types; it will not do anything smart like nested objects/lists.

Example:

assuming your clipboard contains a=1&b=true&c=a,b,c...

poly query-string json --convert

will result in

{
  "a": 1,
  "b": true,
  "c": "a,b,c"   // note that this is NOT ["a", "b", "c"]
}

?foo=bar,baz,bat will be converted as a string of {"foo": "bar,baz,bat"}, not as a list of {"foo": ["bar", "baz", "bat"]} If you want a list to be built, simply use the same query param multiple times.

More complex example (including list and complex object):

assuming your clipboard contains

http://foo.bar.com?a=1&b=true&c=a,b,c&b=false&d={"foo":"bar"}

(note that this contains a url! oooooo....)

running:

poly query-string json --convert --include-url

will result in:

{
  "url": "http://foo.bar.com",  // from --include-url
  "a": 1,
  "b": [true, false],  // multiple 'b' params were combined into a list
  "c": "a,b,c",   // note that this is NOT ["a", "b", "c"]
  "d": {"foo": "bar"}   // oooooo fancy
}

This is all done using the Python builtin ast.literal_eval() -- a completely safe function that will attempt simply to convert the string to a valid Python literal, but does not execute the string as code.

JSON formatting (json)

Manipulate JSON data from the clipboard

All commands start with poly json

  • pretty: pretty-prints the JSON in your clipboard and sends it back to the clipboard
  • one-line: outputs the JSON in your clipboard as a single line of text and sends it back to the clipboard

Base64 (b64)

Encode/Decode Base64 data

  • poly b64 from: Takes base64-encoded data from the clipboard, outputs the decoded data, and sends it back to the clipboard
  • poly b64 to: Takes data from the clipboard, outputs base64-encoded data, and sends it back to the clipboard

Hash Functions

Supports md5, sha1, sha256, and sha512

URL Query Param Encoding/Decoding

  • poly url encode
  • poly url decode

Encodes strings like

a=1&b=true&c=a,b,c&b=false&d={"foo": "bar", "baz": "bat"}

into

a=1&b=true&b=false&c=a%2Cb%2Cc&d=%7B%22foo%22%3A%20%22bar%22%2C%20%22baz%22%3A%20%22bat%22%7D

and decodes them back again.

Both encode/decode also support -q, --quote-plus which allows for encoding spaces as + instead of %20

String Manipulation

  • Line sorting (line-sort): This will attempt to sort the lines of a \n-separated string in your clipboard
  • Spongebob (sponge, spongebob): I WoNDeR What ThIS doEs
  • Smart Quotes (quotes): Replaces those stupid /// with proper quotes "/'
  • [Un]Escape Text (escape/unescape): Add/remove \ in a string for given characters
You might also like...
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Ros command - Unifying the ROS command line tools
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

A Python-based command prompt concept which includes windows command emulation.

PythonCMD A Python-based command prompt concept which includes windows command emulation. Current features: echo: Input your message and it will be cl

Tidier - a simple command line tool that helps you make your files tidy up

Tidier - a simple command line tool that helps you make your files tidy up

Collection of useful command line utilities and snippets to help you organise your workspace and improve workflow.

Collection of useful command line utilities and snippets to help you organise your workspace and improve workflow.

Get latest astronomy job and rumor news in your command line
Get latest astronomy job and rumor news in your command line

astrojobs Tired of checking the AAS job register and astro rumor mill for job news? Get the latest updates in the command line! astrojobs automaticall

Command line tool to keep track of your favorite playlists on YouTube and many other places.

Command line tool to keep track of your favorite playlists on YouTube and many other places.

A command line tool to create a graph representing your Ansible playbook tasks and roles
A command line tool to create a graph representing your Ansible playbook tasks and roles

Ansible Playbook Grapher ansible-playbook-grapher is a command line tool to create a graph representing your Ansible playbook plays, tasks and roles.

pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo

pyGinit pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo Requirements Requirements be

Comments
  • Make poly work on linux - bare minimum.

    Make poly work on linux - bare minimum.

    This is just a quick improvement to do the bare-minimum to make poly work out of the box on linux. Namely,

    • Packages should be installed locally.
    • Some commands need to be Sudo
    • Pillow was missing from the requirements.

    There are some other improvements that could be made to the install script. Suggestion for future improvements:

    1. the clone is done regardless of whether a repo exists or not.
    2. Clone Goes to the cwd; Where the user is may or may not be writeable. Try for ~/ or /tmp
    3. Consider a trap for ensuring cleanup on the bash script.
    4. Probably shouldn't go to /usr/bin/ for the app. Mayhaps /usr/local/bin or ~/.local/bin? Can check path to decide.
    5. Why does it matter if poly exists? what if I want to update it? Overwrite that guy!
    6. Rather than -f /usr/bin/poly, consider command or which to discover it
    7. Consider enabling bash "safe mode"
    8. Mark script with /usr/bin/env bash
    9. Consider removing absolute path commands. Could cause issues on other systems.

    If you want, I can make a ticket for these, if you agree, I just wanted to drop this by while it was in my head. Good work, it's pretty cool!

    opened by tjstub 0
Owner
3DigitDev
3DigitDev
A simple CLI tool for converting logs from Poker Now games to other formats

?? Poker Now Log Converter ?? A command line utility for converting logs from Poker Now games to other formats. Introduction Poker Now is a free onlin

null 6 Dec 23, 2022
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
A simple automation script that logs into your kra account and files your taxes with one command

EASY_TAX A simple automation script that logs into your kra account and files your taxes with one command Currently works for Chrome users. Will creat

leon koech 13 Sep 23, 2021
Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process.

docker-image-size-limit Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process. Read the announcing post. I

wemake.services 102 Dec 14, 2022
Module for converting 2D Python lists to fancy ASCII tables. Table2Ascii lets you display pretty tables in the terminal and on Discord.

table2ascii Module for converting 2D Python lists to a fancy ASCII/Unicode tables table2ascii ?? Installation ??‍?? Usage Convert lists to ASCII table

Jonah Lawrence 40 Jan 3, 2023
Albert launcher extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecular substance, and more

unit-converter-albert-ext Extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecu

Jonah Lawrence 2 Jan 13, 2022
Set of scripts & tools for converting between numbers and major system encoded words.

major-system-converter Set of scripts & tools for converting between numbers and major system encoded words. Uses phonetics instead of letters to conv

null 4 Aug 9, 2022
Ralph is a command-line tool to fetch, extract, convert and push your tracking logs from various storage backends to your LRS or any other compatible storage or database backend.

Ralph is a command-line tool to fetch, extract, convert and push your tracking logs (aka learning events) from various storage backends to your

France Université Numérique 18 Jan 5, 2023
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 3, 2023
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

null 4 Sep 4, 2021