Hacker News new | past | comments | ask | show | jobs | submit login
Pastel: A command-line tool to generate, analyze, convert and manipulate colors (github.com/sharkdp)
264 points by praveenscience on Aug 28, 2019 | hide | past | favorite | 28 comments



This looks really neat. The demo uses a lot of shell pipes though, needing to type "pastel" out for every processing step. It would be convenient if something like

  pastel random | pastel mix red | pastel lighten 0.2 | pastel format hex
could be written

  pastel random mix red lighten 0.2 format hex
(not quite possible, I think) or

  pastel random then mix red then lighten 0.2 then format hex
or something.


GStreamer uses the argument "!" as a pseudo-"|" so you can build multimedia pipelines without actually using Unix pipelines, or repeating the gst-launch command:

https://gstreamer.freedesktop.org/documentation/tutorials/ba...


Having written a large number of CLIs in the past, I've often come across this issue but never had a good solution. This is remarkably simple, elegant, and easily generalized into a CLI framework so it can be implemented with ease. Thank you for sharing this nugget of gold!


Sadly Zsh uses ! for history expansion so they'd all have to be escaped in that shell.


Even in the middle of a line, not just at the start?


Yes, and it's a great feature IMO:

    touch projects/new-lib/readme
    cd !!:1:h


That would be great.

  pastel random ! mix red ! lighten 0.2 ! format hex



Every shell can make its own version, but here's a wrapper in fish which I named pstl:

  eval (echo "pastel $argv" | sed 's/ | / | pastel /g')
Now you can

  pstl "random | mix red | lighten 0.2 | format hex"


Literally last week I was looking for a tool to grep colors from a text file (say an SVG or a theme file) and was about to start writing one...which wasn't going to be even half as neat as this, so thank you very much for sharing


Another great tool from sharkdp written in Rust (such as bat, hyperfine, diskus, fd, etc).


I love every single tool this guy builds


I had to create some diagrams and needed a way to generate palettes programatically, this will come in handy since I can iterate over HSL space and convert back to RGB since the diagram tool only accepts RGB! If the OP is the author please send the info, let me pay you a beer ;)


I was just looking for something that could print hex color codes to the terminal the other day. The best solution I found was some hacky perl script which was hit-or-miss with certain colors, for some odd reason. Much appreciated.


Probably the perl script only supported 256 color modes, 24bit colors from the terminal are a relatively new item in terms of support in terminals.


For us Macheads it looks like there's a brew formula in the works: https://github.com/Homebrew/homebrew-core/pull/43459

I do a fair bit of viz work, this tool could come in handy for generating color schemes I think.


FWIW, Linuxbrew is shaping up to be a solid tool as well.

Want to install your favorite text editor on a server and don't have root? Need a CLI utility and your sysadmin is slow/lazy? System package is ancient and you need a newer version? Linuxbrew solves all of those problems.

Heck, you could even rig up a shell script to toggle among Brew installations in order to create self-contained dev environments, synchronize with a Brewfile, and generate a Brewfile.lock.


  brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/4e60ba14762ad17eef498ce5719aa06bc639d2b1/Formula/pastel.rb


I usually use hslpicker.com for tweaking colors, but this looks useful for seeing an array of colors at once.


I was looking for a quick way to convert RGB 0-255 to RGB float 0.0-1.0 (often used in shaders and other areas of 3D programming) just the other day. This tool doesn't currently seem to support that, would be a nice addition.


Thank you for the feedback. I have added a new "rgb-float" format in the latest release: https://github.com/sharkdp/pastel/releases/tag/v0.5.3


Awesome, thanks!


Is it not sufficient to floating-point divide the input values by 255 ?

Edit: I guess that, even as simple as it would be to implement, it still is another useful output format


Simple to implement yeah, hard for me to do in my head hence the need for a tool :-)


$ command |sed 's/$/\/255/' | bc # or similar?



No comments though, and very few up votes.

From the FAQ (see footer):

"Are reposts ok?

If a story has had significant attention in the last year or so, we kill reposts as duplicates. If not, a small number of reposts is ok."


TIL. I'll keep that in mind for my submitions.

Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: