I am using dracula theme in ubuntu.
I ran program in bashscript but after executing it colorized on next line.
Am I doing any mistake or it is due to theme? How can I fix it?
Here is code: bash.sh
#!/bin/bash
for i in {1..9}
do
for j in {1..9}
do
total=$(( $i $j ))
tmp=$(( $total%2 ))
if [ $tmp -eq 0 ];
then
echo -e -n "\033[47m "
else
echo -e -n "\033[40m "
fi
done
echo ""
done
echo -e "\n"
CodePudding user response:
Yes, it's not connected with Dracula theme.
After all procedures with colors, you must be reset colors:
echo -e "\e[0m"
So, your code must look like this:
#!/bin/bash
for i in {1..9}
do
for j in {1..9}
do
total=$(( $i $j ))
tmp=$(( $total%2 ))
if [ $tmp -eq 0 ];
then
echo -e -n "\033[47m "
else
echo -e -n "\033[40m "
fi
done
echo -e "\e[0m"
More about Bash colors you can see here.