1

I'm trying to start using tmux and 'fixing' the fact that tmux doesn't load my .bashrc on startup. I tried to do all fixes like adding source ~/.bashrc to ~/.profile or creating ~/.bash_profile and adding to that. Even when I start tmux and run source ~/.bashrc nothing changes.

My .bashrc has some minor changes to how the directories are shown after the username and of course the colors. When I start tmux, the directories are shown as they would if nothing was altered in .bashrc and the color is the same as the text color, which in a normal bash session that's not the case.

Does anybody have any idea on how to fix this?

1
1

Since you revealed no exact information about your .bashrc, I'm going to play a psychic and read it remotely.

There is a condition similar to

case "$TERM" in
    xterm-color|xterm-256color) …

and your prompt depends on it. In details it may be like

case "$TERM" in
    xterm-color|xterm-256color) color_prompt=yes;;
esac

and then for example

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

If this is the case then there's the culprit: tmux uses screen, tmux or similar string (such as tmux-256color) as $TERM. The string your tmux uses does not fulfill the condition in your .bashrc for enabling a colored prompt.

While inside Bash inside tmux invoke echo "$TERM". Whatever you get, it should be able to handle colors; so just add it to the condition. Example:

case "$TERM" in
    xterm-color|xterm-256color|screen) …

You can learn about the concept of $TERM from answers to this question.

1
  • Damn, you were spot on. Thanks. I'm sorry for not giving enough details, I just didn't understand what you meant by "what you bashrc looks like" and certainly didn't know how to get that to you. Thank you very much. – arsene Apr 17 '20 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.