Code Update

This commit is contained in:
Christer Warén 2024-06-01 01:11:20 +03:00
parent ca14cb1988
commit a614d63d1c
4 changed files with 49 additions and 16 deletions

View File

@ -1,6 +1,21 @@
wx-header(){ wx-header(){
wx-start if [[ $2 == "h1" ]]
then
echo "=============================="
wx-repeat " " $((30/2-${#1}/2))
echo -n "$wxBold"
echo -n "$1"
echo -n "$wxNormal"
echo ""
echo "=============================="
fi
echo ">> $1 <<" if [[ $2 == "h2" || -z $2 ]]
then
wx-start
wx-repeat " " $((30/2-6/2-${#1}/2))
echo -n ">> $1 <<"
echo ""
echo "------------------------------" echo "------------------------------"
fi
} }

5
src/functions/repeat.sh Normal file
View File

@ -0,0 +1,5 @@
wx-repeat() {
local str=$1 n=$2 spaces
printf -v spaces "%*s" $n " "
printf "%s" "${spaces// /$str}"
}

View File

@ -2,11 +2,7 @@ wx-start(){
echo "" echo ""
echo "" echo ""
echo "" echo ""
echo "==============================" wx-header "Warén CLI" h1
echo -n "$wxBold"
echo " Warén CLI "
echo -n "$wxNormal"
echo "=============================="
mkdir -p $HOME/.config/warengroup &> /dev/null mkdir -p $HOME/.config/warengroup &> /dev/null

31
wx
View File

@ -20,10 +20,31 @@ wxNormal=$(tput sgr0)
declare -Ax config declare -Ax config
wx-header(){ wx-header(){
wx-start if [[ $2 == "h1" ]]
then
echo "=============================="
wx-repeat " " $((30/2-${#1}/2))
echo -n "$wxBold"
echo -n "$1"
echo -n "$wxNormal"
echo ""
echo "=============================="
fi
echo ">> $1 <<" if [[ $2 == "h2" || -z $2 ]]
then
wx-start
wx-repeat " " $((30/2-6/2-${#1}/2))
echo -n ">> $1 <<"
echo ""
echo "------------------------------" echo "------------------------------"
fi
}
wx-repeat() {
local str=$1 n=$2 spaces
printf -v spaces "%*s" $n " "
printf "%s" "${spaces// /$str}"
} }
wx-restricted(){ wx-restricted(){
@ -41,11 +62,7 @@ wx-start(){
echo "" echo ""
echo "" echo ""
echo "" echo ""
echo "==============================" wx-header "Warén CLI" h1
echo -n "$wxBold"
echo " Warén CLI "
echo -n "$wxNormal"
echo "=============================="
mkdir -p $HOME/.config/warengroup &> /dev/null mkdir -p $HOME/.config/warengroup &> /dev/null