I use bash terminals quite a lot in my daily work, and since I chose KDE for my desktop, I naturally use konsole for opening bash sessions. When I start konsole, the first session shows colored output, making it fast and easy to see what is a directory and what is a file on a ls listing, for example. When opening another tab (Ctrl+shift+T) or window (Ctrl+shift+N) though, bash output is not colored anymore. Any reason and quick workaround for that?
EDIT:
The distro I use is Slackware, in its slackware-current version (almost reaching version 14.0 by now). Based on the link supplied in the answer by @terdon, which shows the difference beetween .bash_profile and .bashrc, I compared the environment on the first session (redirected to file /tmp/win1
) with the subsequent ones (redirected to files /tmp/win2
and /tmp/win3
) and, while the difference among the latest is irrelevant:
$ diff /tmp/win2 /tmp/win3
24c24
< declare -x KONSOLE_DBUS_SESSION="/Sessions/7"
---
> declare -x KONSOLE_DBUS_SESSION="/Sessions/8"
47c47
< declare -x SHELL_SESSION_ID="7e9f9937fbfb4000a1ee37ddb8426069"
---
> declare -x SHELL_SESSION_ID="3a4ce4adac174000ba49a6ce8d381467"
the difference between the first and the second sessions' environment shows some hints:
$ diff /tmp/win1 /tmp/win2
2c2
< declare -x CPLUS_INCLUDE_PATH="/usr/lib/qt/include:/opt/kde3/lib/qt3/include:/usr/lib/qt/include:/opt/kde3/lib/qt3/include"
---
> declare -x CPLUS_INCLUDE_PATH="/usr/lib/qt/include:/opt/kde3/lib/qt3/include"
24c24
< declare -x KONSOLE_DBUS_SESSION="/Sessions/6"
---
> declare -x KONSOLE_DBUS_SESSION="/Sessions/7"
31c31
< declare -x LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.7z=01;31:*.ace=01;31:*.ACE=01;31:*.arj=01;31:*.bz2=01;31:*.cpio=01;31:*.deb=01;31:*.dz=01;31:*.gz=01;31:*.jar=01;31:*.lzh=01;31:*.lzma=01;31:*.rar=01;31:*.RAR=01;31:*.rpm=01;31:*.rz=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tlz=01;31:*.trz=01;31:*.txz=01;31:*.tz=01;31:*.tz2=01;31:*.xz=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.aac=01;35:*.AAC=01;35:*.anx=01;35:*.asf=01;35:*.ASF=01;35:*.au=01;35:*.axa=01;35:*.axv=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.divx=01;35:*.DIVX=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2A=01;35:*.m2v=01;35:*.M2V=01;35:*.m4a=01;35:*.M4A=01;35:*.m4p=01;35:*.M4P=01;35:*.m4v=01;35:*.M4V=01;35:*.mid=01;35:*.midi=01;35:*.mka=01;35:*.mkv=01;35:*.MKV=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mp4=01;35:*.MP4=01;35:*.mp4v=01;35:*.mpc=01;35:*.MPC=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.nuv=01;35:*.oga=01;35:*.ogv=01;35:*.ogx=01;35:*.ogg=01;35:*.OGG=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.PNG=01;35:*.ppm=01;35:*.qt=01;35:*.ra=01;35:*.RA=01;35:*.ram=01;35:*.RAM=01;35:*.rm=01;35:*.RM=01;35:*.spx=01;35:*.svg=01;35:*.svgz=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.tiff=01;35:*.TIFF=01;35:*.vob=01;35:*.VOB=01;35:*.wav=01;35:*.WAV=01;35:*.wma=01;35:*.WMA=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xcf=01;35:*.xpm=01;35:*.xspf=01;35:*.xwd=01;35:*.XWD=01;35:*.xvid=01;35:"
---
> declare -x LS_COLORS=""
37c37
< declare -x PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig"
---
> declare -x PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
47c47
< declare -x SHELL_SESSION_ID="98d5491a0f354000896dc496554b5bad"
---
> declare -x SHELL_SESSION_ID="7e9f9937fbfb4000a1ee37ddb8426069"
53a54
> declare -x TOOLS_HOME="/home/claudio/tools"
58c59
< declare -x XDG_CONFIG_DIRS="/etc/xdg:/etc/kde/xdg:/etc/kde/xdg"
---
> declare -x XDG_CONFIG_DIRS="/etc/xdg:/etc/kde/xdg"
Note the variable LS_COLORS is only set on the first session, but it is defined at system level on /etc/profile.d/coreutils-dircolors.sh
(excerpt):
# Set up the LS_COLORS environment:
if [ -f $HOME/.dir_colors ]; then
eval `/bin/dircolors -b $HOME/.dir_colors`
elif [ -f /etc/DIR_COLORS ]; then
eval `/bin/dircolors -b /etc/DIR_COLORS`
else
eval `/bin/dircolors -b`
fi
Also, the variable TOOLS_HOME, which is defined in my .bashrc file, doesn't show on the first session, but it does on the second and third. This leads me to believe that just /etc/profile.d files are being sourced to the first session and only .bashrc to the subsequent ones.