new setup version; more modular
This commit is contained in:
2
zsh/rc
2
zsh/rc
@ -1,6 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
source "$HOME/.config/wryn/env/env"
|
||||
source "$HOME/.config/wryn/env/env.zsh"
|
||||
|
||||
# --- load custom plugins ------------------------------------------
|
||||
|
||||
|
21
zsh/utils/color.zsh
Normal file
21
zsh/utils/color.zsh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/zsh
|
||||
[ ! $COLOR_PATH ] && COLOR_PATH="${0:a:h}/color"
|
||||
|
||||
# use colors by name
|
||||
source "$COLOR_PATH/names.zsh"
|
||||
|
||||
|
||||
# console message helper function
|
||||
source "$COLOR_PATH/console-color-out.zsh"
|
||||
|
||||
|
||||
# write full line messages with semantic name
|
||||
# e.g. 'ERROR : something bad happened' (in red)
|
||||
source "$COLOR_PATH/messages.zsh"
|
||||
|
||||
|
||||
# two-piece message, check message >> run some stuff >> status
|
||||
# the status appears on the same line as the check
|
||||
#
|
||||
# e.g. 'CHECK : installing something... ✔ OK'
|
||||
source "$COLOR_PATH/check.zsh"
|
26
zsh/utils/color/check.zsh
Normal file
26
zsh/utils/color/check.zsh
Normal file
@ -0,0 +1,26 @@
|
||||
function CHECK() {
|
||||
SINGLE_LINE=1 CONSOLE_COLOR_OUT $WHITE $PREFIX_CHK $@'... '
|
||||
}
|
||||
|
||||
function CHECK_RESULT() {
|
||||
local color="$1"
|
||||
local output="$2"
|
||||
printf "\\033[$color""m$output\\033[0m\n"
|
||||
}
|
||||
|
||||
function OK() {
|
||||
CHECK_RESULT $LIGHT_GREEN '✔ OK'
|
||||
[ $1 ] && SUCCESS $@
|
||||
return 0
|
||||
}
|
||||
|
||||
function WARN() {
|
||||
CHECK_RESULT $YELLOW '⚠ WARN'
|
||||
[ $1 ] && WARNING $@
|
||||
return 0
|
||||
}
|
||||
|
||||
function FAIL() {
|
||||
CHECK_RESULT $LIGHT_RED '✖ FAIL'
|
||||
FATAL $@
|
||||
}
|
19
zsh/utils/color/console-color-out.zsh
Normal file
19
zsh/utils/color/console-color-out.zsh
Normal file
@ -0,0 +1,19 @@
|
||||
[ ! $PREFIX_ERR ] && PREFIX_ERR='ERROR '
|
||||
[ ! $PREFIX_FAT ] && PREFIX_FAT='FATAL '
|
||||
[ ! $PREFIX_WRN ] && PREFIX_WRN='WARNING'
|
||||
[ ! $PREFIX_SCS ] && PREFIX_SCS='SUCCESS'
|
||||
[ ! $PREFIX_STS ] && PREFIX_STS='STATUS '
|
||||
[ ! $PREFIX_USR ] && PREFIX_USR='USER '
|
||||
[ ! $PREFIX_BLK ] && PREFIX_BLK=' '
|
||||
[ ! $PREFIX_CHK ] && PREFIX_CHK='CHECK '
|
||||
|
||||
function CONSOLE_COLOR_OUT() {
|
||||
local color="$1"
|
||||
local prefix="$2"
|
||||
|
||||
local message="\\033[$color""m$prefix :: ${@:3}\\033[0m"
|
||||
|
||||
[ ! $SINGLE_LINE ] && message="$message\n"
|
||||
|
||||
printf $message
|
||||
}
|
29
zsh/utils/color/messages.zsh
Normal file
29
zsh/utils/color/messages.zsh
Normal file
@ -0,0 +1,29 @@
|
||||
function ERROR() {
|
||||
CONSOLE_COLOR_OUT $RED $PREFIX_ERR $@
|
||||
}
|
||||
|
||||
function FATAL() {
|
||||
ERROR $@
|
||||
CONSOLE_COLOR_OUT $RED $PREFIX_FAT 'exiting'
|
||||
exit 1
|
||||
}
|
||||
|
||||
function WARNING() {
|
||||
CONSOLE_COLOR_OUT $ORANGE $PREFIX_WRN $@
|
||||
}
|
||||
|
||||
function STATUS() {
|
||||
CONSOLE_COLOR_OUT $PURPLE $PREFIX_STS $@
|
||||
}
|
||||
|
||||
function SUCCESS() {
|
||||
CONSOLE_COLOR_OUT $GREEN $PREFIX_SCS $@
|
||||
}
|
||||
|
||||
function USER_PROMPT() {
|
||||
SINGLE_LINE=1 CONSOLE_COLOR_OUT $CYAN $PREFIX_USR $@
|
||||
}
|
||||
|
||||
function MENU() {
|
||||
CONSOLE_COLOR_OUT $YELLOW $PREFIX_BLK $@
|
||||
}
|
23
zsh/utils/color/names.zsh
Normal file
23
zsh/utils/color/names.zsh
Normal file
@ -0,0 +1,23 @@
|
||||
BLACK='0;30'
|
||||
DARK_GRAY='1;30'
|
||||
|
||||
RED='0;31'
|
||||
LIGHT_RED='1;31'
|
||||
|
||||
GREEN='0;32'
|
||||
LIGHT_GREEN='1;32'
|
||||
|
||||
ORANGE='0;33'
|
||||
YELLOW='1;33'
|
||||
|
||||
BLUE='0;34'
|
||||
LIGHT_BLUE='1;34'
|
||||
|
||||
PURPLE='0;35'
|
||||
LIGHT_PURPLE='1;35'
|
||||
|
||||
CYAN='0;36'
|
||||
LIGHT_CYAN='1;36'
|
||||
|
||||
LIGHT_GRAY='0;37'
|
||||
WHITE='1;37'
|
0
zsh/utils/color/prefix.zsh
Normal file
0
zsh/utils/color/prefix.zsh
Normal file
4
zsh/utils/user-input.zsh
Normal file
4
zsh/utils/user-input.zsh
Normal file
@ -0,0 +1,4 @@
|
||||
function READ_K() {
|
||||
read -k $1
|
||||
echo
|
||||
}
|
Reference in New Issue
Block a user