mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-23 03:51:31 +01:00
zsh: cleanup colors/color functions
This commit is contained in:
parent
481c81c68a
commit
25037bde1f
31
colors.zsh
31
colors.zsh
|
@ -94,3 +94,34 @@ LIGHTCYAN="\e[36m"; LIGHTRED="\033[31m"; LIGHTPURPLE="\033[35m";
|
|||
YELLOW="\e[33m"; WHITE="\033[37m"
|
||||
BACKGROUND_BLACK="\e[40"; BACKGROUND_RED="\033[41";
|
||||
BACKGROUND_GREEN="\e[42"; BACKGROUND_YELLOW="\033[43m"
|
||||
|
||||
|
||||
## Color string with given color. Usage: `color $NAME "string"`, available colors below
|
||||
function color
|
||||
{
|
||||
local color=$1
|
||||
shift 1
|
||||
echo -e "${color}$@${CLEAR}"
|
||||
}
|
||||
|
||||
## These functions return a colored version of the input string. Usage: red "string"
|
||||
function red
|
||||
{
|
||||
echo -e "$Red$@$CLEAR"
|
||||
}
|
||||
function green
|
||||
{
|
||||
echo -e "$Green$@$CLEAR"
|
||||
}
|
||||
function yellow
|
||||
{
|
||||
echo -e "$Yellow$@$CLEAR"
|
||||
}
|
||||
function blue
|
||||
{
|
||||
echo -e "$Blue$@$CLEAR"
|
||||
}
|
||||
function bold
|
||||
{
|
||||
echo -e "$BOLD$@$CLEAR"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
function warning {
|
||||
echo -e "$(color $YELLOW Warning:) $@" >&2
|
||||
}
|
||||
|
||||
function error {
|
||||
echo -e "$(color $RED Error:) $@" >&2
|
||||
}
|
||||
|
||||
function info {
|
||||
echo -e "$(color $GREEN Info:) $@"
|
||||
}
|
||||
|
||||
function switch-asciinema-user
|
||||
{
|
||||
local conf_dir="$HOME/.config/asciinema"
|
||||
|
@ -34,22 +22,22 @@ function switch-asciinema-user
|
|||
fi
|
||||
new_id=$(echo $ids| fzf --height=$(($(wc -l <<< $ids)+2)) ${query} )
|
||||
if [[ -z $new_id ]]; then
|
||||
warning "Keeping curent id ($(color $UNDERLINE ${current_id}))"
|
||||
yellow "Keeping curent id ($(color $UNDERLINE ${current_id}))"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$new_id" == "$current_id" ]]; then
|
||||
warning "id $new_id is already set."
|
||||
yellow "id $new_id is already set."
|
||||
return
|
||||
fi
|
||||
|
||||
local id_file="${conf_dir}/${new_id}"
|
||||
if [[ ! -f ${id_file} ]]; then
|
||||
error "${id_file} does not exist"
|
||||
red "${id_file} does not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
ln -sf "${id_file}" "${conf_dir}/install-id" && \
|
||||
info "Set \"$new_id\"." || \
|
||||
error "Could not set id \"$new_id\". (run with -l for a list of available profiles)"
|
||||
green "Set \"$new_id\"." || \
|
||||
red "Could not set id \"$new_id\". (run with -l for a list of available profiles)"
|
||||
}
|
||||
|
|
|
@ -50,33 +50,20 @@ function ppath
|
|||
echo "$PWD/$1"
|
||||
}
|
||||
|
||||
## Color string with given color. Usage: `color $NAME "string"`, available colors in `colors.sh`
|
||||
function color
|
||||
{
|
||||
local color=$1
|
||||
shift 1
|
||||
echo -e "${color}$@${CLEAR}"
|
||||
|
||||
function warning {
|
||||
echo -e "${Yellow}Warning:$CLEAR $@" >&2
|
||||
}
|
||||
|
||||
function error {
|
||||
echo -e "${Red}Error:$CLEAR $@" >&2
|
||||
}
|
||||
|
||||
## These functions return a colored version of the input string. Usage: red "string"
|
||||
function red
|
||||
{
|
||||
echo -e "$Red$@$CLEAR"
|
||||
}
|
||||
function green
|
||||
{
|
||||
echo -e "$Green$@$CLEAR"
|
||||
}
|
||||
function blue
|
||||
{
|
||||
echo -e "$Blue$@$CLEAR"
|
||||
}
|
||||
function bold
|
||||
{
|
||||
echo -e "$BOLD$@$CLEAR"
|
||||
function info {
|
||||
echo -e "${Green}Info:$CLEAR $@"
|
||||
}
|
||||
|
||||
|
||||
## Flashes the screen until user presses a key
|
||||
function flasher
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user