Unlike other terminal emulators with kitty terminals I have no colors on bash prompt.
I am using ubuntu, my PS1 is \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
What have I to setup for this?
Thanks
Unlike other terminal emulators with kitty terminals I have no colors on bash prompt.
I am using ubuntu, my PS1 is \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
What have I to setup for this?
Thanks
Kitty may not be recognised as a color terminal...
What is the $TERM environment variable set to?
In gnome-terminal it says:
$ echo $TERM
xterm-256color
In kitty it says:
$ echo $TERM
xterm-kitty
Check your .bashrc for this line:
xterm-color|*-256color) color_prompt=yes;;
Add xterm-kitty to it, like this:
xterm-color|*-256color|xterm-kitty) color_prompt=yes;;
Now restart kitty.
I think it will work with the following code in your ~/.bashrc
I don't know if you need to tamper with the variable TERM, but it is there in my
~/.bashrc. I borrowed it years ago, and don't know/remember what is actually necessary.
if [ "${TERM:0:5}" == "xterm" ]
then
typeset TERM=xterm-color # force colour prompt
fi
function statstring {
RC=$?
if [ "0" != $RC ]; then
printf "[$RC] "
fi
}
case "$TERM" in
xterm-color)
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
if [ "$USER" = root ]; then
PS1='\[\033[01;31m\]$(statstring)\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \$ '
else
PS1='\[\033[01;31m\]$(statstring)\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \$ '
fi
;;
*)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
;;
esac
if [ "$TERM" == "xterm-color" ]
then
typeset TERM=xterm # force basic prompt
fi
Explanation: ANSI escape sequences in PC computers start with ESC [ and in echo statements we can use \0033 (ASCII: 3*8+3 = 27 for ESC). See this link for a detailed description of ANSI sequences.
There is also an 'error code message' when a command return with an error code. This is controlled by the function statstring.