Compare commits
6 Commits
de9454b324
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cfcb399d20 | |||
|
|
4183072ea8 | ||
| e1b576a4b7 | |||
| f49c74f12b | |||
|
|
4cf9387cb8 | ||
| 6dbb80d10f |
44
bashcols
44
bashcols
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
# vim: syntax=bash:
|
||||||
|
|
||||||
eval "reset_esc=\"\\e[0m\""
|
reset_esc='\e[0m'
|
||||||
|
|
||||||
# applies the given color id, executes the command, then resets the color
|
# applies the given color id, executes the command, then resets the color
|
||||||
function colout() {
|
function colout() {
|
||||||
@@ -9,9 +9,9 @@ function colout() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local color=$1
|
local color="$1"
|
||||||
shift
|
shift
|
||||||
tput setaf $color
|
tput setaf "$color"
|
||||||
"$@"
|
"$@"
|
||||||
tput sgr0
|
tput sgr0
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ function defcol() {
|
|||||||
function dispcollist() {
|
function dispcollist() {
|
||||||
local width=${1:-16}
|
local width=${1:-16}
|
||||||
local idx=0
|
local idx=0
|
||||||
for colid in `seq 1 256`; do
|
for colid in {1..256}; do
|
||||||
colout $colid printf "%3s " $colid
|
colout $colid printf "%3s " $colid
|
||||||
idx=$(($idx+1))
|
idx=$(($idx+1))
|
||||||
if [[ $(($idx % $width)) -eq 0 ]]; then
|
if [[ $(($idx % $width)) -eq 0 ]]; then
|
||||||
@@ -49,24 +49,24 @@ function dispcollist() {
|
|||||||
function colthis {
|
function colthis {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
shift
|
shift
|
||||||
eval "printf \"\${${name}_esc}$@$reset_esc\""
|
eval "printf \"%s\" \"\${${name}_esc}$@$reset_esc\""
|
||||||
}
|
}
|
||||||
|
|
||||||
# default colors
|
# default colors
|
||||||
defcol red 1
|
defcol red 1
|
||||||
defcol green 2
|
defcol green 2
|
||||||
defcol brown 3
|
defcol brown 3
|
||||||
defcol blue 4
|
defcol blue 4
|
||||||
defcol magenta 5
|
defcol magenta 5
|
||||||
defcol cyan 6
|
defcol cyan 6
|
||||||
defcol white 7
|
defcol white 7
|
||||||
defcol grey 8
|
defcol grey 8
|
||||||
defcol redl 9
|
defcol redl 9
|
||||||
defcol greenl 10
|
defcol greenl 10
|
||||||
defcol yellow 11
|
defcol yellow 11
|
||||||
defcol bluel 12
|
defcol bluel 12
|
||||||
defcol magenta 13
|
defcol magenta 13
|
||||||
defcol cyanl 14
|
defcol cyanl 14
|
||||||
defcol whitel 15
|
defcol whitel 15
|
||||||
defcol black 16
|
defcol black 16
|
||||||
|
|
||||||
|
|||||||
22
bashparam
Normal file
22
bashparam
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
declare -A __params
|
||||||
|
|
||||||
|
function has_param {
|
||||||
|
[[ -z ${__params[$1]} ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_param {
|
||||||
|
echo "${__params[$1]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set_param <longname> <value>
|
||||||
|
function set_param {
|
||||||
|
if [[ -z $2 ]]; then
|
||||||
|
>&2 echo "${FUNCNAME}: non-zero value expected"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
$__params[${1:2}]=${2}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user