Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#174·pastel

It would be great to be able to paint gradients in TMUX and Powerline directly with pastel

Author: purplefishiesCreated Nov 21, 2022Updated Jan 14, 2023

Hi ,

It would be really nice to be able to paint gradients directly with pastel. You have the ability to read from stdin a set of colors such as those generated by pastel. It would really be nice to be able to take that input stream and "paint" a text string using a modified version of the output.

For instance, tmux requires that the colors have the prefix "#[fg=" and suffix "]".

I created a modified bash script that generates the required formats to create a gradient in tmux but it would be much nicer to be able to do it directly with speedy pastel.

#!/bin/bash

color_from="$1"
color_to="$2"
text="$3"

length=${#text}

colors=$(pastel gradient -n "$length" "$color_from" "$color_to" -sLCh)

i=0
for color in $colors; do
    echo -ne "#[fg=$(pastel format hex "$color")]${text:$i:1}"
    i=$((i+1))
done
printf "\n"

Is there any guidance you can give for how you could see the syntax being ? I'm happy to work on a PR to make this work

Source: sharkdp/pastel

View original on GitHubView discussion on GitHub