42 lines
1.1 KiB
Bash
42 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
##### bash framework
|
|
# some useful bash functions to make things easier
|
|
|
|
## use printf for safety purposes
|
|
# http://www.etalabs.net/sh_tricks.html
|
|
# @param string what to say
|
|
say () { printf %s\\n "$*" ; }
|
|
sayn () { printf %s "$*" ; }
|
|
|
|
## check if user is root
|
|
root () { [[ "$EUID" -eq 0 ]] ; }
|
|
|
|
## colors
|
|
# use ANSI escape codes
|
|
normal () { printf '\033[0m' ; }
|
|
red () { printf '\033[0;31m' ; }
|
|
green () { printf '\033[0;32m' ; }
|
|
black () { printf '\033[0;30m' ; }
|
|
brown () { printf '\033[0;33m' ; }
|
|
orange () { printf '\033[0;33m' ; }
|
|
blue () { printf '\033[0;34m' ; }
|
|
purple () { printf '\033[0;35m' ; }
|
|
cyan () { printf '\033[0;36m' ; }
|
|
gray () { printf '\033[0;37m' ; }
|
|
grey () { printf '\033[1;30m' ; }
|
|
lred () { printf '\033[1;31m' ; }
|
|
lgreen () { printf '\033[1;32m' ; }
|
|
yellow () { printf '\033[1;33m' ; }
|
|
lblue () { printf '\033[1;34m' ; }
|
|
lpurple (){ printf '\033[1;35m' ; }
|
|
lcyan () { printf '\033[1;36m' ; }
|
|
white () { printf '\033[1;37m' ; }
|
|
|
|
# quick styler, usage "style *color*"
|
|
style() {
|
|
[[ "$1" == "" ]] && orange || $1
|
|
sayn " ::: "
|
|
normal
|
|
}
|