Skip to content

Instantly share code, notes, and snippets.

@dudeofawesome
Last active July 6, 2022 10:22
Show Gist options
  • Save dudeofawesome/ce2d84b08a508fdaf0a066ca039c8ce8 to your computer and use it in GitHub Desktop.
Save dudeofawesome/ce2d84b08a508fdaf0a066ca039c8ce8 to your computer and use it in GitHub Desktop.
Easily export Fish Shell colors
#!/usr/bin/env fish
function rainbowify -d "Rainbow-ify text"
set -l RAINBOW red FF8800 yellow green blue purple
set LENGTH (string length $argv)
set SPLIT (string split '' $argv)
for i in (seq $LENGTH)
set PERC (math -s2 $i / $LENGTH)
set _STEP (math "$PERC * 6.0")
set STEP (printf '%.0f' (echo "$_STEP/1" | bc -l))
if [ $STEP = 0 ]
set STEP 1
end
echo -n (set_color $RAINBOW[$STEP])$SPLIT[$i]
end
set_color normal
end
echo "#!/usr/bin/env fish" > colors.fish
echo "" >> colors.fish
chmod +x colors.fish
for i in (set -n | string match 'fish*_color*')
echo "set -U $i $$i" >> colors.fish
end
echo "echo \""(rainbowify "Fish colors have been set")"\"" >> colors.fish
echo "Exported your "(rainbowify "colors")" to "(set_color cyan --underline)"colors.fish"(set_color normal)
echo "Now, just copy that file to your remote machine and run it."
@bchenSyd
Copy link

bchenSyd commented Mar 7, 2021

nice work. thanks!

  1. line 27 should be set -U
  2. [ will cause fish to interoperate and fish is complaining bracket doesn't match. line 30, better to do
    echo echo \"(rainbowify xxxx \"

@dudeofawesome
Copy link
Author

Good call, I've updated the script accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment