djcev.com

//

Git Repos / dotfiles / bin / cev_print.sh

Last update to this file was on 2021-12-13 at 10:18.

Show cev_print.sh

#!/bin/sh
#
# Copyright (c) 2017-2021, Cameron Vanderzanden. Available under the
# terms of the 2-clause BSD license. Please see the file "LICENSE" in
# the root dir of this repository for more information.
#
#- cev_print.sh 2017/01/17 cev, last updated 2021/12/07. (was lib_print.sh)
#
# functions for pretty printing.

print_help() { grep "^## " "$0" | cut -c 4-; }
print_version() { grep "^#- " "$0" | cut -c 4-; }

print_filenotfound() {
[ -z "$self" ] && self="$0"
printf "%b%s:%b " "$_self" "$self" "$_clear" >&2
printf "%bfile %b%s " "$_norm" "$_error" "$*" >&2
printf "%bnot found!%b\n" "$_norm" "$_clear" >&2
}

print_directorynotfound() {
print_self error
printf "%bdirectory %b%s " "$_norm" "$_error" "$*" >&2
printf "%bnot found!%b\n" "$_norm" "$_clear" >&2
}

print_noexe() {
print_self error
printf "%b%s%b is not executable!%b\n" "$_error" "$*" "$_norm" "$_clear" >&2
}

print_nofile() {
print_self error
printf "%bno file specified.%b\n" "$_norm" "$_clear" >&2
}

print_self() {
[ -z "$self" ] && self="$0"
if [ -z "$1" ]; then
printf "%b%s:%b " "$_self" "$self" "$_clear"
else
printf "%b%s:%b " "$_self" "$self" "$_clear" >&2
fi

}

print_unknownfiletype() {
print_self error
printf "%b%s%b is an unknown filetype!%b\n" \
"$_high" "$*" "$_norm" "$_clear" >&2
}

set_colors_true() {
_clear="\033[0m"
_self="\033[00;38;2;146;131;116m"
_error="\033[00;31m"
_error_high="\033[00;1;31m"
_norm="\033[00;38;2;213;196;161m"
_high="\033[00;37m"
}

set_colors_256() {
_clear="\033[0m"
_self="\033[00;38;5;245m"
_error="\033[00;31m"
_error_high="\033[00;1;31m"
_norm="\033[00;38;5;250m"
_high="\033[00;37m"
}

set_colors_16() {
_clear="\033[0m"
_self="\033[00;34m"
_error="\033[00;31m"
_error_high="\033[00;1;31m"
_norm="\033[00;37m"
_high="\033[00;1;37m"
}

set_colors_2() {
_clear=""
_self=""
_error=""
_error_high=""
_norm=""
_high=""
}

case $TERM in
rxvt-unicode-256color) set_colors_256 ;;
rxvt-256color) set_colors_256 ;;
rxvt-unicode) set_colors_16 ;;
rxvt-mono) set_colors_2 ;;
rxvt*) set_colors_2 ;;
xterm-256color) set_colors_true ;;
xterm-color) set_colors_16 ;;
xterm*) set_colors_2 ;;
screen-256color) set_colors_256 ;;
screen*) set_colors_2 ;;
*) set_colors_2 ;;
esac

Return to the top of this page or return to the overview of this repo.

Log cev_print.sh

Date Commit Message Author + -
2021-12-13 Expanded redshift background.sh, misc. changes cev +101  

Return to the top of this page or return to the overview of this repo.