💄 Saved asci colors
This commit is contained in:
parent
addaa750ec
commit
6bd4aee6e6
4 changed files with 244 additions and 1 deletions
1
aliases
1
aliases
|
|
@ -161,7 +161,6 @@ alias {html,html_pp}="hxnormalize -e"
|
||||||
# stock tickers
|
# stock tickers
|
||||||
alias ticker="ticker -w SPY,QQQ,DIA,IWM,VIX"
|
alias ticker="ticker -w SPY,QQQ,DIA,IWM,VIX"
|
||||||
alias {mop,market,stonks,stocks}="cd ~/aur_packages/mop && go run ./cmd/mop/main.go && cd"
|
alias {mop,market,stonks,stocks}="cd ~/aur_packages/mop && go run ./cmd/mop/main.go && cd"
|
||||||
alias {reddit,rd}="tuir"
|
|
||||||
alias qwiki="wik -i"
|
alias qwiki="wik -i"
|
||||||
alias toolongdidntread="tldr"
|
alias toolongdidntread="tldr"
|
||||||
alias cheatsheet="cheat"
|
alias cheatsheet="cheat"
|
||||||
|
|
|
||||||
23
scripts/ansi_colours
Executable file
23
scripts/ansi_colours
Executable file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
for i in range(30, 37+1):
|
||||||
|
print ("\033[%dm%d\t\t\033[%dm%d" %(i, i, i + 60, i + 60));
|
||||||
|
|
||||||
|
print("\\033[XXm")
|
||||||
|
|
||||||
|
print("\033[39m\\033[49m - Reset colour")
|
||||||
|
print("\\033[2K - Clear Line")
|
||||||
|
print("\\033[<L>;<C>H OR \\033[<L>;<C>f puts the cursor at line L and column C.")
|
||||||
|
print("\\033[<N>A Move the cursor up N lines")
|
||||||
|
print("\\033[<N>B Move the cursor down N lines")
|
||||||
|
print("\\033[<N>C Move the cursor forward N columns")
|
||||||
|
print("\\033[<N>D Move the cursor backward N columns")
|
||||||
|
print("\\033[2J Clear the screen, move to (0,0)")
|
||||||
|
print("\\033[K Erase to end of line")
|
||||||
|
print("\\033[s Save cursor position")
|
||||||
|
print("\\033[u Restore cursor position")
|
||||||
|
print(" ")
|
||||||
|
print("\\033[4m Underline on")
|
||||||
|
print("\\033[24m Underline off")
|
||||||
|
print("\\033[1m Bold on")
|
||||||
|
print(("\\033[21m Bold off"))
|
||||||
83
scripts/asci
Executable file
83
scripts/asci
Executable file
|
|
@ -0,0 +1,83 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
asci() { echo -e "\e[${1}m${*:2}\e[0m"; }
|
||||||
|
bold() { asci 1 "$@"; }
|
||||||
|
italic() { asci 3 "$@"; }
|
||||||
|
underline() { asci 4 "$@"; }
|
||||||
|
strikethrough() { asci 9 "$@"; }
|
||||||
|
red() { asci 31 "$@"; }
|
||||||
|
|
||||||
|
bold this text is written using the bold function
|
||||||
|
italic and this text is written using the italic function
|
||||||
|
underline same for underline...
|
||||||
|
strikethrough and for strikethrough...
|
||||||
|
red and even with red!
|
||||||
|
|
||||||
|
echo -e "\e[3mitalic\e[0m"
|
||||||
|
echo -e "\e[1mbold\e[0m"
|
||||||
|
echo -e "\e[4munderline\e[0m"
|
||||||
|
echo -e "\e[9mstrikethrough\e[0m"
|
||||||
|
echo -e "\e[31mred\e[0m"
|
||||||
|
echo -e "\e[32mgreen\e[0m"
|
||||||
|
echo -e "\e[33myellow\e[0m"
|
||||||
|
echo -e "\e[34mblue\e[0m"
|
||||||
|
echo -e "\e[35mpurple\e[0m"
|
||||||
|
echo -e "\e[36mcyan\e[0m"
|
||||||
|
echo -e "\e[37mwhite\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[31;1;3mitalic and red\033[0m"
|
||||||
|
|
||||||
|
# %2d two digits printed this way
|
||||||
|
printf "\e[1;34m%2d\e[0m\n" 42
|
||||||
|
# %s indicates string
|
||||||
|
printf "\e[1;35m%s\e[0m\n" "and this is a printf string in purple 42"
|
||||||
|
|
||||||
|
echo -e "\033[30;0mwhite regular\e[0m"
|
||||||
|
echo -e "\033[30;1mgrey bold\e[0m"
|
||||||
|
echo -e "\033[30;4mgrey underline\e[0m"
|
||||||
|
echo -e "\033[30;7mgrey background, black letters\e[0m"
|
||||||
|
echo -e "\033[40;1mgrey background, white letters\e[0m"
|
||||||
|
echo -e "\033[40;4mgrey background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[40;7mwhite background, grey letters\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[31;1mred bold\e[0m"
|
||||||
|
echo -e "\033[31;4mred underline\e[0m"
|
||||||
|
echo -e "\033[31;7mred background, black letters\e[0m"
|
||||||
|
echo -e "\033[41;1mred background, white letters\e[0m"
|
||||||
|
echo -e "\033[41;4mred background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[41;7mwhite background, red letters\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[32;1mgreen bold\e[0m"
|
||||||
|
echo -e "\033[32;4mgreen underline\e[0m"
|
||||||
|
echo -e "\033[32;7mgreen background, black letters\e[0m"
|
||||||
|
echo -e "\033[42;1mgreen background, white letters\e[0m"
|
||||||
|
echo -e "\033[42;4mgreen background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[42;7mgrey background, green letters\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[33;1myellow bold\e[0m"
|
||||||
|
echo -e "\033[33;4myellow underline\e[0m"
|
||||||
|
echo -e "\033[33;7myellow background, black letters\e[0m"
|
||||||
|
echo -e "\033[43;1myellow background, white letters\e[0m"
|
||||||
|
echo -e "\033[43;4myellow background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[43;7mwhite background, yellow letters\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[34;1mblue bold\e[0m"
|
||||||
|
echo -e "\033[34;4mblue underline\e[0m"
|
||||||
|
echo -e "\033[34;7mblue background, black letters\e[0m"
|
||||||
|
echo -e "\033[44;1mblue background, white letters\e[0m"
|
||||||
|
echo -e "\033[44;4mblue background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[44;7mwhite background, blue letters\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[35;1mpurple bold\e[0m"
|
||||||
|
echo -e "\033[35;4mpurple underline\e[0m"
|
||||||
|
echo -e "\033[35;7mpurple background, black letters\e[0m"
|
||||||
|
echo -e "\033[45;1mpurple background, white letters\e[0m"
|
||||||
|
echo -e "\033[45;4mpurple background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[45;7mwhite background, purple letters\e[0m"
|
||||||
|
|
||||||
|
echo -e "\033[36;1mcyan bold\e[0m"
|
||||||
|
echo -e "\033[36;4mcyan underline\e[0m"
|
||||||
|
echo -e "\033[36;7mcyan background, black letters\e[0m"
|
||||||
|
echo -e "\033[46;1mcyan background, white letters\e[0m"
|
||||||
|
echo -e "\033[46;4mcyan background, white letters, underline\e[0m"
|
||||||
|
echo -e "\033[46;7mwhite background, cyan letters\e[0m"
|
||||||
138
scripts/hex2rgb.sh
Executable file
138
scripts/hex2rgb.sh
Executable file
|
|
@ -0,0 +1,138 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# convert hexadecimal colors to bash rgb format!
|
||||||
|
function hex2rgb() {
|
||||||
|
local raw copy hex r g b alpha modifier delim pipe
|
||||||
|
delim=";" pipe=cat
|
||||||
|
function hex2rgb_usage() {
|
||||||
|
cat<<HEX2RGB_EOL
|
||||||
|
|
||||||
|
$(cyn)h$(grn)e$(ylw)x$(orn)2$(red)r$(mag)g$(blu)b$(reset) · $(ital)Convert hexadecimal colors to bash-friendly RGB$(reset)
|
||||||
|
|
||||||
|
$(bold && undl)USAGE$(reset)
|
||||||
|
|
||||||
|
\$ $(bold && hex2rgb 8dddff)hex2rgb$(reset && dark) [-t|-c|-r] [-d delimiter] [-b|-f] <$(reset && ital)hex-color ...$(reset && dark)>$(reset)
|
||||||
|
|
||||||
|
$(bold && undl)OPTIONS$(reset)
|
||||||
|
|
||||||
|
$(ital && bold && ylw)-b, --background$(reset) format output as a $(bold && undl)background$(reset) color
|
||||||
|
$(ital && bold && ylw)-f, --foreground$(reset) format output as a $(bold && undl)foreground$(reset) color
|
||||||
|
$(ital && bold && ylw)-t, --tee$(reset) pipe output to stdout and to the clipboard
|
||||||
|
$(ital && bold && ylw)-c, --copy$(reset) pipe output to the clipboard
|
||||||
|
$(ital && bold && ylw)-r, --raw$(reset) outputs raw rgb values, no escape sequences
|
||||||
|
$(ital && bold && ylw)-d, --delim$(reset) specify a delimiter for output (default is ';')
|
||||||
|
|
||||||
|
$(bold && undl)EXAMPLES$(reset)
|
||||||
|
|
||||||
|
\$ hex2rgb 8cc055
|
||||||
|
$(2rgb 8cc055)
|
||||||
|
|
||||||
|
\$ hex2rgb -d ', ' -r -- ff3a00
|
||||||
|
$(hex2rgb ff3a00)$(hex2rgb -d ', ' -r -- ff3a00)$(reset)
|
||||||
|
|
||||||
|
HEX2RGB_EOL
|
||||||
|
}
|
||||||
|
while [[ "$1" == -* ]]; do
|
||||||
|
case $1 in
|
||||||
|
(-[bB]|--background)
|
||||||
|
modifier=48;;
|
||||||
|
(-[fF]|--foreground)
|
||||||
|
modifier=38;;
|
||||||
|
(-[tT]|--tee)
|
||||||
|
pipe=tee;;
|
||||||
|
(-[cC]|--copy)
|
||||||
|
pipe=pbcopy;;
|
||||||
|
(-[rR]|--raw)
|
||||||
|
pipe=cat; raw=1;;
|
||||||
|
(-[dD]|--delim)
|
||||||
|
[ -n "$2" ] && { delim=$2; shift; };;
|
||||||
|
(-[eE]|--esc)
|
||||||
|
[ -n "$2" ] && { esc=$2; shift; };;
|
||||||
|
(-[hH]|"-?"|"?"|--help)
|
||||||
|
hex2rgb_usage
|
||||||
|
return;;
|
||||||
|
(--)
|
||||||
|
shift; break;;
|
||||||
|
(-*)
|
||||||
|
echo "Unknown option: $1" >&2;
|
||||||
|
hex2rgb_usage
|
||||||
|
return 1;;
|
||||||
|
(*)
|
||||||
|
break;;
|
||||||
|
esac
|
||||||
|
shift;
|
||||||
|
done
|
||||||
|
if (($# > 0)); then
|
||||||
|
for hex in "$@"; do
|
||||||
|
hex="${hex//'#'/}"
|
||||||
|
if [ "${#hex}" = "3" ]; then
|
||||||
|
# expand shorthand
|
||||||
|
hex="${hex:0:1}${hex:0:1}${hex:1:1}${hex:1:1}${hex:2:1}${hex:2:1}"
|
||||||
|
elif [ "${#hex}" = "4" ]; then
|
||||||
|
# extract alpha channel (4th digit) from hex, convert it to decimal range 0-1.0
|
||||||
|
alpha="$(echo "ibase=16; ${hex:3:1}" | bc -l)"
|
||||||
|
# expand shorthand
|
||||||
|
hex="${hex:0:1}${hex:0:1}${hex:1:1}${hex:1:1}${hex:2:1}${hex:2:1}"
|
||||||
|
elif [ "${#hex}" = "6" ]; then
|
||||||
|
# expand shorthand
|
||||||
|
hex="${hex:0:2}${hex:2:2}${hex:4:2}"
|
||||||
|
elif [ "${#hex}" = "8" ]; then
|
||||||
|
# extract alpha channel (7-8th digits) from hex, convert to decimal range 0-1.0
|
||||||
|
alpha="$(echo "ibase=16; ${hex:6:2}" | bc -l)"
|
||||||
|
# expand shorthand
|
||||||
|
hex="${hex:0:2}${hex:2:2}${hex:4:2}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf -v r "%d" 0x"${hex:0:2}"
|
||||||
|
printf -v g "%d" 0x"${hex:2:2}"
|
||||||
|
printf -v b "%d" 0x"${hex:4:2}"
|
||||||
|
if [ -z "$raw" ]; then
|
||||||
|
__osc "${modifier:-38}" "2" "$r" "$g" "$b" | $pipe
|
||||||
|
else
|
||||||
|
printf "%s%d%s%d%s%d" "${modifier:+"${modifier}${delim}2${delim}"}" "$r" "$delim" "$g" "$delim" "$b" | $pipe
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
hex2rgb_usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# helper function to render the color with escape sequence as a sort of preview
|
||||||
|
function 2rgb() {
|
||||||
|
printf $(hex2rgb "$@")' \\033['$(hex2rgb -d ';' -r "$@")'m \033[0m'
|
||||||
|
}
|
||||||
|
|
||||||
|
alias bold="__osc 01"
|
||||||
|
alias undl="__osc 04"
|
||||||
|
alias ital="__osc 03"
|
||||||
|
alias dark="__osc 02"
|
||||||
|
alias flsh="__osc 05"
|
||||||
|
alias inv="__osc 07"
|
||||||
|
alias reset="__osc 00"
|
||||||
|
alias blk="__osc 38 02 00 00 00"
|
||||||
|
alias red="__osc 01 31"
|
||||||
|
alias grn="__osc 01 32"
|
||||||
|
alias ylw="__osc 01 33"
|
||||||
|
alias orn="__osc 01 38 02 255 143 51"
|
||||||
|
alias blu="__osc 01 34"
|
||||||
|
alias mag="__osc 01 35"
|
||||||
|
alias cyn="__osc 01 36"
|
||||||
|
alias wht="__osc 38 02 255 255 255"
|
||||||
|
alias gry="__osc 37"
|
||||||
|
alias blk_b="__osc 48 02 00 00 00"
|
||||||
|
alias red_b="__osc 01 41"
|
||||||
|
alias grn_b="__osc 01 42"
|
||||||
|
alias ylw_b="__osc 01 43"
|
||||||
|
alias orn_b="__osc 01 48 02 255 143 51"
|
||||||
|
alias blu_b="__osc 01 44"
|
||||||
|
alias mag_b="__osc 01 45"
|
||||||
|
alias cyn_b="__osc 01 46"
|
||||||
|
alias wht_b="__osc 48 02 255 255 255"
|
||||||
|
|
||||||
|
function __osc() {
|
||||||
|
local esc=033 str ifs=$IFS;
|
||||||
|
IFS=';'; str="$*"; IFS=$ifs;
|
||||||
|
printf '\033['${str:-0}m
|
||||||
|
}
|
||||||
|
alias osc=__osc
|
||||||
Loading…
Add table
Add a link
Reference in a new issue