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

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
Owner
3DigitDev
3DigitDev
An question and answer shell environment based on xonsh using ansible for setup

An question and answer shell environment based on xonsh using ansible for setup

Steven Hollingsworth 2 Jan 11, 2022
Python CLI utility and library for manipulating SQLite databases

sqlite-utils Python CLI utility and library for manipulating SQLite databases. Some feature highlights Pipe JSON (or CSV or TSV) directly into a new S

Simon Willison 1.1k Jan 04, 2023
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli.

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

Janardon Hazarika 17 Dec 11, 2022
A command line tool to publish ads on ebay-kleinanzeigen.de

kleinanzeigen-bot Feedback and high-quality pull requests are highly welcome! About Installation Usage Development Notes License About kleinanzeigen-b

83 Dec 26, 2022
swarmexec executes command in swarm service

Swarmexec swarmexec executes command in swarm service Install pip install git+https://github.com/filimon43g/swarmexec.git Config In swarm_config.ini

Phil 2 Nov 23, 2021
Program Command Line Interface (CLI) Sederhana: Pemesanan Nasi Goreng Hekel

Program ini merupakan aplikasi yang berjalan di dalam command line (terminal). Program ini menggunakan built-in library python yaitu argparse yang dapat menerima parameter saat program ini dijalankan

Habib Abdurrasyid 5 Nov 19, 2021
Simple command line tool to train and deploy your machine learning models with AWS SageMaker

metamaker Simple command line tool to train and deploy your machine learning models with AWS SageMaker Features metamaker enables you to: Build a dock

Yasuhiro Yamaguchi 5 Jan 09, 2022
nbcommands bring the goodness of Unix commands to Jupyter notebooks.

nbcommands nbcommands bring the goodness of Unix commands to Jupyter notebooks. Installation You can simply use pip to install nbcommands: $ pip insta

Vinayak Mehta 181 Dec 23, 2022
OneDriveExplorer - A command line and GUI based application for reconstructing the folder structure of OneDrive from the UserCid.dat file

OneDriveExplorer - A command line and GUI based application for reconstructing the folder structure of OneDrive from the UserCid.dat file

Brian Maloney 100 Dec 13, 2022
Un module simple pour demander l'accord de l'utilisateur dans une CLI.

Demande de confirmation utilisateur pour CLI Présentation ask_lib est un module pour le langage Python proposant une seule fonction; ask(). Le but pri

CallMePixelMan 7 May 09, 2022
Color preview command-line tool written in python

Color preview command-line tool written in python

Arnau 1 Dec 27, 2021
A simple command line virtual operating system, written in python

Virtual operating system A simple virtual operating system written in python. (Under development). Currently, the following commands are supported: Co

B.Jothin kumar 7 Nov 15, 2022
This is my fetch, with ascii arts from neofetch and internet

deadfetch This is my fetch, with ascii arts from neofetch and internet Installation First what you need its python Fedora sudo dnf install python3 sud

DedSec 8 Jan 20, 2022
🦎 A NeoVim plugin for highlighting visual selections like in a normal document editor!

🦎 HighStr.nvim A NeoVim plugin for highlighting visual selections like in a normal document editor! Demo TL;DR HighStr.nvim is a NeoVim plugin writte

Pocco81 222 Jan 03, 2023
Command Line (CLI) Application to automate creation of tasks in Redmine, issues on Github and the sync process of them.

Task Manager Automation Tool (TMAT) CLI Command Line (CLI) Application to automate creation of tasks in Redmine, issues on Github and the sync process

Tiamat 5 Apr 12, 2022
A Multipurpose bot with many Commands made using Pycord

This repo has all of the commands you will ever need in a discord bot. a Multipurpose discord bot

Pogrammar 42 Dec 18, 2022
Multifunctional library for creating progress bars.

👋 Content Installation Using github Using pypi Quickstart Flags Useful links Documentation Pypi Changelog TODO Contributing FAQ Bar structure ⚙️ Inst

DenyS 27 Jan 01, 2023
Cli tool to browse and play anime

browse and watch anime (scrape from gogoanime) (wip) basically ani-cli but in python cuz python good demo dependencies mpv installation from pypi pip

sheep padowo 2 Apr 20, 2022
QueraToCSV is a simple python CLI project to convert the Quera results file into CSV files.

Quera is an Iranian Learning management system (LMS) that has an online judge for programming languages. Some Iranian universities use it to automate the evaluation of programming assignments.

Amirmahdi Namjoo 16 Nov 11, 2022
Get Air Quality Index for your city/country 😷

Air Quality Index CLI Get Air Quality index for your City. Installation $ pip install air-quality-cli Contents Air Quality Index CLI Installation Cont

Yankee 40 Oct 21, 2022