One of the machines I log into via ssh doesn't give me a colored prompt, despite setting it via .bashrc
. The .bashrc
part in question is
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
if [ $(id -u) -eq 0 ];
then # you are root, make the prompt red
PS1='${debian_chroot:+($debian_chroot)}\[\e[00;33m\]\u\[\e[00m\]@\[\e[00;34m\]\h\[\e[00m\]:\[\e[00;36m\]\w\[\e[00m\]\e[01;31m#\e[00m '
else
PS1='${debian_chroot:+($debian_chroot)}\[\e[00;32m\]\u\[\e[00m\]@\[\e[00;34m\]\h\[\e[00m\]:\[\e[00;36m\]\w\[\e[00m\]$ '
fi
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
and I use it on several other machines with the desired result.
I have no idea why this particular computer doesn't use this .bashrc
. If I use
export PS1='${debian_chroot:+($debian_chroot)}\[\e[00;32m\]\u\[\e[00m\]@\[\e[00;34m\]\h\[\e[00m\]:\[\e[00;36m\]\w\[\e[00m\]$ '
(the line from above), my prompt gets the desired format. /etc/bash.bashrc
exists, also /etc/profile
, both look OK to me.
Also, if I ssh into this computer, the xterm title doesn't get set. Normally, it gets set to user@host for this machine. I suspect the same root cause, but I have no idea where to look.
While using ssh, you are getting login shell.
From
~/.profile
So make sure this file exists in home directory of the user in which you are trying to login. If it doesn't exists then create the file and force it to read the
~/.bashrc
file by typing this -