uploaded hue-shades.py and tildepath.sh

This commit is contained in:
jan6 2019-04-06 08:36:28 -04:00
parent 5b50ef6743
commit edd73275b1
2 changed files with 49 additions and 0 deletions

38
hue-shades.py Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
from colorsys import hsv_to_rgb
from sys import argv
from argparse import ArgumentParser,RawDescriptionHelpFormatter
parser = ArgumentParser(
description='display 24-bit "true color" shades of any HSV hue',
formatter_class=RawDescriptionHelpFormatter,
epilog="example: \n"+
"`%(prog)s 03` for orange-ish red interpreted as HSV hue of 0.03")
parser.add_argument('hue',
action='store', default="75",
nargs="?",
help='Set the hue color, fractional part of a float (the "01" in 0.01)',
type=str)
hue=parser.parse_args().hue
#fallback if argparse fails its default assignment
try: hue=float("0."+hue)
# if hue else float("0.75")
except ValueError: print("invalid hue, please use only integers!");exit()
#filler char
filler=''
for i in range(2,100,2):
for j in range(0,100):
fore=hsv_to_rgb(hue,j/100,i/100);
foreground={"red":int(fore[0]*255),"green":int(fore[1]*255),"blue":int(fore[2]*255)}
back=hsv_to_rgb(hue,j/100,(i+1)/100);
background={"red":int(back[0]*255),"green":int(back[1]*255),"blue":int(back[2]*255)}
print(
"\x1b[38;2;"+str(foreground["red"])+";"+str(foreground["green"])+";"+str(foreground["blue"])+"m"+
"\x1b[48;2;"+str(background["red"])+";"+str(background["green"])+";"+str(background["blue"])+"m"+
str(filler)+
"\x1b[0m",end='');
print("")

11
tildepath.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
if test "$1";then
if test "$1" = "--help";then
echo "replaces /home/ with ~ making friendlier paths.";
echo "files relative to current directory";
else
lsopt="-d1f";ls="$1";
fi;
else lsopt="-f1";ls="./";
fi
ls $lsopt "$ls"|rev|cut -f1 -d" "|rev|sed -e "s\\^\\$PWD/\\" -e 's./home/.~.'