A version that is a bit more 'general' - should work with a varied environment: (depends on terminfo)
Insert this in your $HOME/.bashrc:
function fgtab {
echo "tput setf/setb - Foreground/Background table"
for f in {0..7}; do
for b in {0..7}; do
echo -en "$(tput setf $f)$(tput setb $b) $f/$b "
done
echo -e "$(tput sgr 0)"
done
}
# The prompt in a somewhat Terminal -type independent manner:
cname="$(tput setf 3)"
csgn="$(tput setf 4)"
chost="$(tput setf 2)"
cw="$(tput setf 6)"
crst="$(tput sgr 0)"
PS1="\[${cname}\]\u\[${csgn}\]@\[${chost}\]\h:\[${cw}\]\w\[${csgn}\]\$\[${crst}\] "
Then execute source ~/.bashrc.
After that, fgtab will display a color table with numbers. Those numbers are for tput setf n and tput setb n where 'n' is the number, 'f' stands for 'foreground' and 'b' stands for 'background' color.
tput sgr 0 will reset foreground and background colors to default.
And as you can see, changing the colors used for the prompt becomes really easy (just edit the same number in $HOME/.bashrc as you wish).
Add an $(tput setb n) in $cname if you wish to have ALL of the prompt with background n.
Open
~/.bashrc
in text editor and uncomment line:#force_color_prompt=yes
to be:
force_color_prompt=yes
save then execute
source ~/.bashrc
I came up with this solution:
copy this and add it at the end of .bashrc file:
save the file and restart bashrc:
For a full list of available colors and further options look up these links:
A version that is a bit more 'general' - should work with a varied environment:
(depends on terminfo)
Insert this in your
$HOME/.bashrc
:Then execute
source ~/.bashrc
.After that,
fgtab
will display a color table with numbers. Those numbers are fortput setf n
andtput setb n
where 'n' is the number, 'f' stands for 'foreground' and 'b' stands for 'background' color.tput sgr 0
will reset foreground and background colors to default.And as you can see, changing the colors used for the prompt becomes really easy (just edit the same number in
$HOME/.bashrc
as you wish).Add an
$(tput setb n)
in$cname
if you wish to have ALL of the prompt with background n.If you are using Termux then you can Install zshell which will change everything in your terminal, You can read this post fo the installation.https://www.learntermux.tech/2020/02/how-to-install-z-shell-best-theme-for-TERMUX-2020.html
I've been having trouble making "force-color-prompt" to work in Ubuntu 20 using Kitty/Putty.
But notice the following code in the default Ubuntu 20 .bashrc file: case "$TERM" in xterm-color|*-256color) color_prompt=yes;; esac
So in Kitty, go to
Then change "Terminal-type string" from "xterm" to "xterm-color" and viola!