1. 5
  1.  

  2. 2

    Author here (duh)

    Poly is a text-processing CLI (for now) tool that parses your clipboard and transforms text in-place for you.

    I have been an avid user of Boop on MacOS for a while now, but it’s always had some stuff I disliked, or some features I missed. Plus, the workflow always felt a little clunky.

    I decided to make a sleeker command-line app for myself that could do a lot of the similar functionality!

    I welcome any and all criticism, issues, PRs, or general insults to my person!

    Future work:

    • Make poly into a pip package so it can be imported and used in scripts
    • Make a PyQt UI for it a-la Boop, or Albert
    • More features!
    1. 2

      Some quick initial reactions:

      • I’m not sure if I’d use this myself, but I like the idea of bridging the GUI copy/paste world and the industrial text-processing of the CLI world
      • Rather than one tool that does everything, you might consider just making a minimal tool that watches the clipboard and can pipe it through arbitrary shell-scripts, and then include some shell-scripts as defaults
        • For example, having a special line-sort command built in is nice, but everybody has /usr/bin/sort so you might as well use it
      • You’re right, curl | sudo bash is generally a bad idea, and should be unnecessary in this case
        • The most robust thing would be to add a setup.py and publish to PyPI so people can install with pip3 --user install or pipx or whatever
        • The second-best thing would be for your install.sh script to make a virtualenv (python3 -m venv ~/.config/poly/venv && ~/.config/poly/venv/bin/pip install -r requirements.txt) and then copy the poly script to ~/.local/bin and rewrite the #! to point at ~/.config/poly/venv/bin/python3
      • Instead of (or in addition to) running an external script, how about checking for a prefix on the clipboard content?
        • For example, the user could type calc:3+4*5, then select it and Cmd-C, Cmd-V to paste 23
      1. 1

        On macOS, you can use pbpaste to write the contents of the pasteboard to stdout and then pbcopy to read from stdin and store in the pasteboard. On X11 systems, xclip or xsel combine both features and apply to the clipboard and selection buffers, respectively.

        It’s trivial to assemble these into pipelines in the shell that read from the clipboard, run arbitrary filters between them, and then put the contents back. This isn’t even limited to text: both the Mac and X11 versions of the tools let you do things like request the PNG version of the clipboard contents, pass it through ImageMagick, and then write it back as JPEG (or some other image format) - I’ve actually used a variant of this to pull text from the keyboard, format it using LaTeX, and stick it back as PDF, though on macOS the Text Services API is a better way of doing this.

        1. 1

          Thanks for the feedback!

          The most robust thing would be to add a setup.py and publish to PyPI so people can install with pip3 –user install or pipx or whatever

          That’s definitely the plan going forward – I wanted to have this available through multiple formats

          you might consider just making a minimal tool that watches the clipboard and can pipe it through arbitrary shell-scripts, and then include some shell-scripts as defaults

          That definitely works if this stays a CLI app, but my hope was to eventually make this an import-able library, a GUI app, and a CLI app – Especially in the case of the import-able library, I can’t just use arbitrary bash scripts and pipes for that, so I need to be able to support the same functionality using pure python.

          The second-best thing would be for your install.sh script to make a virtualenv

          This is an interesting idea, I hadn’t thought to do that! It’s a good option, I’ll look into getting that working.

          how about checking for a prefix on the clipboard content?

          I can see the appeal, but I think I prefer it the way it is right now, rather than having a program that’s constantly monitoring and modifying your clipboard on the fly. I could see a lot of privacy and edge-case issues cause behavior you don’t necessarily want that way.