adds different styles for term or no term

This commit is contained in:
2019-05-15 13:43:51 +02:00
parent a9775f4d9b
commit bcdfeb6f88

30
main.sh
View File

@@ -1,10 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Configure styling
if [[ -n "$TERM" ]]
then
inverse="$(tput setab 7)$(tput setaf 0)" inverse="$(tput setab 7)$(tput setaf 0)"
success="$(tput setab 2)$(tput bold)" bold="$(tput bold)"
error="$(tput setab 1)$(tput bold)" success="$(tput setab 2)$bold"
underline=$(tput smul) info="$(tput setaf 6)$bold"
warning="$(tput setaf 3)$bold"
error="$(tput setab 1)$bold"
reset=$(tput sgr0) reset=$(tput sgr0)
else
inverse=""
bold="[["
success="[["
info="[["
warning="[["
error="[["
reset="]]"
fi
export BOG_TITLE_PRINTED=0 export BOG_TITLE_PRINTED=0
@@ -46,7 +60,7 @@ footer () {
section () { section () {
read title read title
echo ":::::" echo ":::::"
echo ":(*) $title..." echo ":$bold(*) $title...$reset"
} }
result () { result () {
@@ -54,9 +68,9 @@ result () {
if [ $exit_code -eq 0 ] if [ $exit_code -eq 0 ]
then then
echo ":)=> $success Ok $reset ****" echo ":)=> $success Ok $reset"
else else
echo ":(!> $error Error $reset ****" echo ":(!> $error Error $reset"
fi fi
} }
@@ -71,13 +85,13 @@ output () {
output::warning () { output::warning () {
while read line while read line
do do
echo ":::<!> $line" echo ":::$warning<!>$reset $line"
done done
} }
output::info () { output::info () {
while read line while read line
do do
echo ":::<?> $line" echo ":::$info<?>$reset $line"
done done
} }