MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

(SOLVED) command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 1:32 pm

Hi,

For some reason on one of my Pi's the command line is now only showing white text on a black background.

$PS1 and $LS_COLORS show

Code: Select all

pi@Pi-3B-plus:~$ echo $PS1
${debian_chroot:+($debian_chroot)}\u@\h:\w\$
pi@Pi-3B-plus:~$ echo $LS_COLORS

pi@Pi-3B-plus:~$ 
I've no idea why this suddenly happened and I've spent a load of time searching around on the internet trying to find a fix but have not been able to find a solution, quite likely because my first language is English rather than Linux :)

However, if I execute the following command the prompt immediately turns green with "~ $" showing blue as I would expect.
pi@Pi-3B-plus:~$ export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\]"
pi@Pi-3B-plus:~ $
I have also tried setting $LS_COLORS copying the $LS_COLORS info from another Pi using command

Code: Select all

pi@Pi-3B-plus:~ $export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
pi@Pi-3B-plus:~ $ls
but that makes no difference and the text all remains white, and when I reboot the prompt return to all white text again.

I am finding this is making life rather awkward as an example an ls command shows all text as white so it is a pain trying to remember which items in the ls output are files, directories and executable scripts etc.

Can someone help me fix this please?


MrEngman
Last edited by MrEngman on Fri Dec 13, 2019 7:55 pm, edited 1 time in total.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 1:40 pm

Somebody/something changed $TERM?

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:14 pm

trejan wrote:
Fri Dec 13, 2019 1:40 pm
Somebody/something changed $TERM?
No idea what that is, however, command

Code: Select all

pi@Pi-3B-plus:~ $echo $TERM
xterm
pi@Pi-3B-plus:~ $
shows the same on the faulty Pi 3B+ as above and on my other Pi's . e.g working Pi Zero

Code: Select all

pi@Pi-0-b:~ $ echo $TERM
xterm
pi@Pi-0-b:~ $


EDIT: Looking at xterm it appears to be the same on the faulty Pi3 B+ and a working one, a Pi B+. Both running Raspbian stretch.



MrEngman
Last edited by MrEngman on Fri Dec 13, 2019 2:27 pm, edited 1 time in total.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:26 pm

Does /usr/bin/dircolors exist? If it does exist, can you run it? It won't enable colour support if that binary is missing.

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:30 pm

It exists and appears to run

Code: Select all

pi@Pi-3B-plus:~ $dircolors
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS
pi@Pi-3B-plus:~ $


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:32 pm

Does it have an alias for ls if you just run "alias"?

It should show:

Code: Select all

$ alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias ls='ls --color=auto'
It is all setup in $HOME/.bashrc

Code: Select all

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi
LS_COLORS being empty implies that section isn't being run. Has something overwritten your .bashrc file? You can get the stock copy back by coping /etc/skel/.bashrc to $HOME/.bashrc

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:35 pm

Looks like this may well be the issue. alias shows nothing.

Code: Select all

pi@Pi-3B-plus:~ $alias
pi@Pi-3B-plus:~ $

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:36 pm

See my edited post above about your .bashrc file.

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 2:49 pm

$HOME/.bashrc contains the section you showed.

I copied /etc/skel/.bashrc to $HOME/.bashrc but it makes no difference. Rebooted just in case I needed to but the problem still exists.



MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 3:10 pm

Odd. It looks like it isn't even loading .bashrc

What does echo $SHELL say?

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 3:41 pm

Code: Select all

pi@Pi-3B-plus:~ $echo $SHELL
/bin/bash
pi@Pi-3B-plus:~ $


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 3:52 pm

Does $HOME/.profile exist? Stock copy is /etc/skel/.profile

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 4:43 pm

trejan wrote:
Fri Dec 13, 2019 3:52 pm
Does $HOME/.profile exist? Stock copy is /etc/skel/.profile
Yes

Code: Select all

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 4:50 pm

Not sure why it isn't working. Everything looks to be correct. Grasping at straws now.

.bashrc and .profile should have -rw-r--r-- permissions and user/group should be your user.

You can try running "bash -v" and it'll show you everything its loading. The .bashrc files for alias and dircolors should be in there if you scroll up a bit. Type exit afterwards to get rid of this extra shell.

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 5:01 pm

Just run the command bash and lo and behold the text colours are now working.

No idea what is causing the issue but that command fixed it, temporarily. Rebooting and the text is back to all white again. Running bash again and the colours for the prompt, dirs., scripts etc. return.

Hopefully that may give you a clue to the issue.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 5:05 pm

.bashrc and .profile look as you expect.

Code: Select all

pi@Pi-3B-plus:~ $ ls -l .bashrc .profile
-rw-r--r-- 1 pi pi 3523 Dec 13 14:42 .bashrc
-rw-r--r-- 1 pi pi  675 Mar 13  2018 .profile

bash -v shows

Code: Select all

pi@Pi-3B-plus:~ $ bash -v
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
        function command_not_found_handle {
                # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
                   /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
                   /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
                else
                   printf "%s: command not found\n" "$1" >&2
                   return 127
                fi
        }
fi
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# 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
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
#                                                          -*- shell-script -*-
#
#   bash_completion - programmable completion functions for bash 4.1+
#
#   Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
#             © 2009-2013, Bash Completion Maintainers
#                     <bash-completion-devel@lists.alioth.debian.org>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2, or (at your option)
#   any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software Foundation,
#   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#   The latest version of this software can be obtained here:
#
#   http://bash-completion.alioth.debian.org/
#
#   RELEASE: 2.1

if [[ $- == *v* ]]; then
    BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
else
    BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
fi

if [[ ${BASH_COMPLETION_DEBUG-} ]]; then
    set -v
else
    set +v
fi
unset BASH_COMPLETION_ORIGINAL_V_VALUE

# ex: ts=4 sw=4 et filetype=sh


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 5:12 pm

Yeah. The .bashrc file is fine which is why when you run bash again it gives you the colours.

The problem is that the bash spawned by lxterminal isn't running in interactive mode. Not sure why though. If you run lxterminal, it should spawn a new window. Does this bash have colour?

Is this a custom shortcut you've made for the terminal or are you running the one in the start menu? Have you modified any of the configuration for that shortcut or for lxterminal itself?

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 5:25 pm

trejan wrote:
Fri Dec 13, 2019 5:12 pm
Yeah. The .bashrc file is fine which is why when you run bash again it gives you the colours.

The problem is that the bash spawned by lxterminal isn't running in interactive mode. Not sure why though. If you run lxterminal, it should spawn a new window. Does this bash have colour?

Is this a custom shortcut you've made for the terminal or are you running the one in the start menu? Have you modified any of the configuration for that shortcut or for lxterminal itself?
I'm running Raspbian Lite, no gui or no lxterminal anyway.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 5:36 pm

MrEngman wrote:
Fri Dec 13, 2019 5:25 pm
I'm running Raspbian Lite, no gui or no lxterminal anyway.
That would have been helpful to state in the original post. You said your TERM variable was set to xterm which implies running the full GUI but if you're running Raspbian Lite then something weird is going on. It should be "linux" if you're using the console or SSH. How are you logging into this Pi? Nothing weird you've done to your configuration?

No idea why your login shell isn't in interactive mode. Everything appears to be setup properly with .profile and .bashrc. I don't think .bash_profile or .bash_login exists since running bash again works.

I guess you can check what shell is set. Running "grep youruser /etc/passwd" should have /bin/bash at the end of the line.

User avatar
rpdom
Posts: 17399
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 6:55 pm

trejan wrote:
Fri Dec 13, 2019 5:36 pm
You said your TERM variable was set to xterm which implies running the full GUI but if you're running Raspbian Lite then something weird is going on. It should be "linux" if you're using the console or SSH.
That depends on what you are connecting from.

I connect to my Raspbian Buster Lite Pis from a laptop running the Debian Raspberry Pi Desktop. TERM on the laptop is xterm and the same when I connect with SSH to the Pi.
Unreadable squiggle

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 6:59 pm

rpdom wrote:
Fri Dec 13, 2019 6:55 pm
That depends on what you are connecting from.

I connect to my Raspbian Buster Lite Pis from a laptop running the Debian Raspberry Pi Desktop. TERM on the laptop is xterm and the same when I connect with SSH to the Pi.
Yeah. SSH will pass it through but still would be handy to know how you're connecting in the first place. Still no idea what bash isn't running in interactive mode though.

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 7:04 pm

trejan wrote:
Fri Dec 13, 2019 5:36 pm
MrEngman wrote:
Fri Dec 13, 2019 5:25 pm
I'm running Raspbian Lite, no gui or no lxterminal anyway.
That would have been helpful to state in the original post. You said your TERM variable was set to xterm which implies running the full GUI but if you're running Raspbian Lite then something weird is going on. It should be "linux" if you're using the console or SSH. How are you logging into this Pi? Nothing weird you've done to your configuration?
I have 8 various Pis running and am connected to all using SSH. Only one has a GUI, a PI4, and the rest using Raspbian Lite. However, running echo $TERM returns xterm on all of them.

Other than changing to a new password and setting a hostname I don't usually make any other changes when setting up a new SD card. I write images on my Win7 laptop using balenaEtcher and copy files wpa_supplicant.conf and ssh to the boot partition before using them on a Pi.
No idea why your login shell isn't in interactive mode. Everything appears to be setup properly with .profile and .bashrc. I don't think .bash_profile or .bash_login exists since running bash again works.

I guess you can check what shell is set. Running "grep youruser /etc/passwd" should have /bin/bash at the end of the line.
In my home directory running ls -A shows .bashrc, .bash_profile, .bash_logout and .bash_history but not .bash_login, however, .bash_login does not appear in any of my other Pi's either and they are all OK.

Running "grep pi /etc/passwd" returns

Code: Select all

pi:x:1000:1000:,,,:/home/pi:/bin/bash
which is the same on all my other Pi's.

OH NO :o :o :o

OK, think I've found the issue. My home directory contained a file .bash_profile and none of my other Pi's had the file. Removing it and now the coloured text is back. I compile several out of tree wifi drivers which are available on my web site http://downloads.fars-robotics.net/ for people to download as required. I recently installed and compile binutils and a new version of gcc to compile 64 bit wifi drivers for Raspbian 64bit. I needed to add a directory where the 64bit compilers were install to $PATH. I couldn't make the change to $PATH permanent and I had to update $PATH every time I rebooted but I then found some info on the internet saying add the changes to $PATH to file .bash_profile. Creating the .bash_profile file now obviously screwed things up.

Thank you for the time you've taken to look at the issue and sorry it seems I messed things up.

One last point if you don't mind. Can you suggest how I can update the $PATH permanently so when I reboot I don't need to keep manually updating the $PATH.

My PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games and I need to add /opt/aarch64/bin/

Thanks for your time looking at this problem.

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

trejan
Posts: 2327
Joined: Tue Jul 02, 2019 2:28 pm

Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 7:37 pm

MrEngman wrote:
Fri Dec 13, 2019 7:04 pm
OK, think I've found the issue. My home directory contained a file .bash_profile and none of my other Pi's had the file. Removing it and now the coloured text is back.
Yeah. I've worked out why it was doing this now and why I didn't think .bash_profile existed.

The overly complicated explanation is that bash has two modes and they work in slightly different ways.

The initial login shell is what you get when you log in and it checks for .bash_profile, .bash_login, and .profile in that order. It'll load the first one it finds and then ignore the rest. Your .bash_profile was overriding this as it is higher priority in the list. All .profile does is load .bashrc and then add some private bin directories to your path.

When you ran bash by hand, it wasn't running as a login shell. This works slightly differently. It still checks for .bash_profile, .bash_login, and .profile but the critical part is that it will also check for .bashrc.

The non-login shell bash was running .bashrc anyway which is why it was confusing that only the login shell was broken.
MrEngman wrote:
Fri Dec 13, 2019 7:04 pm
One last point if you don't mind. Can you suggest how I can update the $PATH permanently so when I reboot I don't need to keep manually updating the $PATH.
Add "PATH=/opt/aarch64/bin:$PATH" to the end of .profile and log out then log back in again.

MrEngman
Posts: 4051
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

(SOLVED) Re: command line does not show coloured text for prompt, dirs, scripts etc.

Fri Dec 13, 2019 7:45 pm

Thank you very much trejan,

Setting .profile as you suggest works.



MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

Return to “Troubleshooting”