diff --git a/colors.zsh b/colors.zsh index 3b6e3f7..e0d6841 100755 --- a/colors.zsh +++ b/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" +} diff --git a/functions/asciinema.zsh b/functions/asciinema.zsh index 39aba3c..90f2c8f 100644 --- a/functions/asciinema.zsh +++ b/functions/asciinema.zsh @@ -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)" } diff --git a/functions/misc.zsh b/functions/misc.zsh index 5c25e1b..4277a32 100755 --- a/functions/misc.zsh +++ b/functions/misc.zsh @@ -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 {