You are not logged in.

#1 2011-10-30 01:09:28

newarch2011
Member
Registered: 2011-09-18
Posts: 41

bashrc colors not working in CLI mode

i have been running an arch web server in virtualbox and i have it set to only use runlevel 3, no gui at all. i set colors in my ~/.bashrc file according to the wiki and i dont get the color. i have it setup for a different color if i connect via SSH which shows normally. i have the lines set correctly and have them even in another real arch install but no luck on this VM.  any ideas why this would be happening?

Last edited by newarch2011 (2011-10-30 01:10:25)

Offline

#2 2011-10-30 10:24:42

sealemar
Member
Registered: 2011-10-30
Posts: 32

Re: bashrc colors not working in CLI mode

can you show your ~/.bashrc?

Offline

#3 2011-10-30 15:28:21

newarch2011
Member
Registered: 2011-09-18
Posts: 41

Re: bashrc colors not working in CLI mode

Here is the code from the machine in question. I do have another machine with the same thing, just different colors, and it works fine though the second machine does use LXDE.

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

txtclr='\e[0m'
txtblue='\e[0;34m'
txtbblue='\e[0;94m'

HISTCONTROL=ignoreboth

alias ls='ls --color=auto'

if [ -n "$SSH_CLIENT" ]; then
    PS1="\[$txtblue\][\u@\h \W]\$ \[$txtclr\]"
else
    PS1="\[$txtbblue\][\u@\h \W]\$ \[$txtclr\]"
fi

Last edited by newarch2011 (2011-10-30 15:28:58)

Offline

#4 2011-10-30 15:36:46

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: bashrc colors not working in CLI mode

Try adding the following to ~/.bash_profile:

[[ -f "$HOME/.bashrc ]] && . "$HOME/.bashrc"

From deep in the very long manual (I don't blame you for not reading it).

When bash is invoked as an interactive login shell, or as a non-interactive
shell with the --login option, it first reads and  executes  commands  from
the  file  /etc/profile,  if that file exists.  After reading that file, it
looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,  in  that  order,
and reads and executes commands from the first one that exists and is read‐
able.  The --noprofile option may be used when  the  shell  is  started  to
inhibit this behavior.

When an interactive shell that is not a login shell is started, bash  reads
and  executes  commands  from  ~/.bashrc, if that file exists.  This may be
inhibited by using the --norc option.  The --rcfile file option will  force
bash to read and execute commands from file instead of ~/.bashrc.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#5 2011-10-30 16:09:35

newarch2011
Member
Registered: 2011-09-18
Posts: 41

Re: bashrc colors not working in CLI mode

Stebalien wrote:

Try adding the following to ~/.bash_profile:

[[ -f "$HOME/.bashrc ]] && . "$HOME/.bashrc"

From deep in the very long manual (I don't blame you for not reading it).

When bash is invoked as an interactive login shell, or as a non-interactive
shell with the --login option, it first reads and  executes  commands  from
the  file  /etc/profile,  if that file exists.  After reading that file, it
looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,  in  that  order,
and reads and executes commands from the first one that exists and is read‐
able.  The --noprofile option may be used when  the  shell  is  started  to
inhibit this behavior.

When an interactive shell that is not a login shell is started, bash  reads
and  executes  commands  from  ~/.bashrc, if that file exists.  This may be
inhibited by using the --norc option.  The --rcfile file option will  force
bash to read and execute commands from file instead of ~/.bashrc.

I am not understanding what that manual is stating. Am I not using an interactive shell?

Offline

#6 2011-10-30 17:09:37

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: bashrc colors not working in CLI mode

After searching a bit more, it appears that ssh shells are also login shells so something is probably sourcing your ~/.bashrc and my answer doesn't apply. In response to your last post, you are using an interactive login shell. Bash only sources ~/.bashrc for non-login interactive shells (second quote).


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#7 2011-10-31 05:49:12

sealemar
Member
Registered: 2011-10-30
Posts: 32

Re: bashrc colors not working in CLI mode

add

echo something

to the end of your ~/.bashrc and see whether it is really echoed or not, so that you'll be sure that ~/.bashrc is or is not executed

Offline

#8 2011-11-02 12:28:32

roygbiv
Member
Registered: 2011-05-18
Posts: 204

Re: bashrc colors not working in CLI mode

Put the following in ~/.bash_profile: source ~/.bashrc

Offline

Board footer

Powered by FluxBB