Are you certain this isn't (partially) a vim
configuration issue?
vim
mostly bases its filetype detection on whole names (e.g. .profile
) or extensions (.sh
). The file you gave is called (I believe) .bash_prompt
, which won't match known bash or shell types.
When you load it, what is the detected type, and is it different on each system?
:set filetype?
If it's not filetype=sh
then try
:set syn=sh
(I'm guessing one at least says conf
filetype, that highlights #
comments TODO
and '
"
quoted strings).
I suspect SLES uses a distinct vim-data
package, this should contain various syntax and color scripts, check if this is installed on the SLES11 system.
To see what formatting is applied to line numbering do:
:highlight LineNr
If you don't see ctermfg=3
(color terminal forground= yellow) then that explains why yellow is "missing".
A change in detected filetype will explain why you are "missing" magenta (red and magenta aren't the same color, btw) on highlighted strings, and "missing" yellow if LineNr has changed.
If you have the xterm source to hand, you can also run some of its colour test scripts which can query all the colour entries:
perl vttests/256colors2.pl # fast, show all colors
perl vttests/query-color.pl 0-15 # slow, uninterruptable
You might also find the colortest.vim script useful, start vim
and run
:runtime syntax/colortest.vim
Within vim
, run :help xterm-color
for further advice on making sure that the base colors are set as expected.
Try this to check what is Xterm thinks its base colors should be (only read when XTerm starts up):
xrdb -query | grep -i vt100.color
Well as you quite correctly guessed setf
is not correct capability for setting foreground color in context of xterm-256color
(screen-256color
) terminfo entry. You should use setaf
(set foreground color using ANSI escape).
$ echo $TERM
screen-256color
$ infocmp -1 | grep setf
$ infocmp -1 | grep setaf
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
Note:
- you should not need to do
alias tmux='TERM=xterm-256color tmux'
, make sure your terminal emulator when started reports correct value of TERM=xterm-256color
- if (1) is true then
tmux
will correctly set your TERM
to screen-256color
inside it, also it will for example correctly set it if you are running on linux console to screen.linux
, there might be case you need to manipulate it but generaly not
Best Answer
The prompt variable
$PS1
was probably not set, so the built-in default\s-\v\$
is used.When bash starts up interactively, it sources a configuration file, usually either
~/.bashrc
or~/.bash_profile
, presuming they exist, and this is how a fancier prompt is set. Fromman bash
:Not having your prompt set can occur in two different contexts then, login shells and non-login shells. If you use a display manager to log directly into the GUI, you don't encounter login shells unless you switch to a virtual console (via, e.g. CtrlAlt + F1 to F6). However, you can test your bash login profile in the GUI by opening a new login shell explicitly:
bash -l
.Problem occurs with non-login shells
If the problem occurs with, e.g., normal GUI terminals, then either your
~/.bashrc
is missing, or it has been edited to exclude sourcing a global file, probably/etc/bashrc
.If
~/.bashrc
does not exist, there should be a/etc/skel/.bashrc
used to create it for new users. Simply copy that file into your home directory, and your default prompt should come back for the next new shell you open.If
~/.bashrc
does exist, check to see if there is a line somewhere that sources/etc/bashrc
:If not, check if that file exists (it should, at least on most linux distros) and add such a line to your
~/.bashrc
.Problem occurs with login shells
If the problem occurs with login shells as well as non-login shells, the problem is probably the same as above. If it occurs only with login shells, you either don't have one of the files mentioned for login shells under the INVOCATION quote above, or they don't source your
~/.bashrc
, which is normal on most linux distros. If none of those files exists, create~/.bash_profile
with this in it:This allows you, for the most part, to keep your configuration in one file (
~/.bashrc
).If no matter what you do you cannot get a prompt back, you can create one and put it into
~/.bashrc
this way:This is because $PS1 is set and has a default value for interactive shells, and you don't want to set it otherwise since other things may use this value to determine whether this is an interactive environment.
The bash man page contains a section PROMPTING which describes how to set a prompt with dynamic features such as your user name and current working directory, which would be, e.g.,:
There's a guide to using color here. Pay attention to the fact that you should enclose non-printed characters in
\[
and\]
(there's a discussion of this at the end of the answer about colors).