When I create a new tmux session, my prompt pulls from a default bash configuration and I have to manually run source ~/.bashrc for my customized prompt.


I am using a RHEL 7 machine. I began noticing this behavior after a bash update a while back, but haven't gotten around to asking the question until now (and am not sure which update this began happening around).

For example, I've customized my prompt to look like:

[user@hostname ~]$

Whenever I start a new tmux session, it uses what appears to be the bash default:


A quick run of source ~/.bashrc always fixes the issue, but it's annoying that I have to do this every time I want to fix something small. Any ideas on how to get tmux to do this automatically again?

If any more information is needed, I am happy to provide.


For reference, I have my tmux.conf file below, although it is hardly what you could call custom.

setw -g mode-keys vi

# reload tmux.conf
bind r source-file ~/.tmux.conf \; display-message " ✱ ~/.tmux.conf is reloaded"

As far as I know, by default tmux runs a login shell. When bash is invoked as an interactive login shell, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile. So you have to put source ~/.bashrc in one of those files.

Another way to solve this issue is to put in your file .tmux.conf the line:

set-option -g default-shell "/bin/bash"
| improve this answer | |
  • 1
    I added the source ~/.bashrc line to my .bash_profile, tried logging out and back in, create a new tmux session, but no change. Any ideas? – Justin Nov 8 '16 at 2:52
  • 1
    Try to put in your file .tmux.conf the line set-option -g default-shell "/bin/bash". This should solve your issue (at least I hope so)! – andreatsh Nov 8 '16 at 22:06
  • After reloading my tmux configuration, this solved my issue! Want to modify your answer or create a new one? I would be happy to mark it as accepted. :) – Justin Nov 17 '16 at 4:24
  • You're kind, I quickly modified my answer! – andreatsh Nov 17 '16 at 15:08
  • 2
    Note for macOS users: if you've installed bash via Homebrew and this doesn't work, change "/bin/bash" to "/usr/local/bin/bash". – user278117 Apr 5 '18 at 14:48

This is related to the Bash init files. By default, ~/.bashrc is used in an interactive, non-login shell. It won't be sourced in a login shell. Tmux uses a login shell by default. Hence, shells started by tmux skip ~/.bashrc.

default-command shell-command

The default is an empty string, which instructs tmux to create a login shell using the value of the default-shell option.

Init files for Bash,

  1. login mode:
    1. /etc/profile
    2. ~/.bash_profile, ~/.bash_login, ~/.profile (only first one that exists)
  2. interactive non-login:
    1. /etc/bash.bashrc (some Linux; not on Mac OS X)
    2. ~/.bashrc
  3. non-interactive:
    1. source file in $BASH_ENV


The weird interactive, non-login loading requirement confuses people in other situations as well. The best solution is to change the loading requirement of ~/.bashrc as interactive only, which is exactly what some distros, like Ubuntu, are doing.

# write content below into ~/.profile, or ~/.bash_profile

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

This should be the solution you desire. And I recommend every Bash user setup this in the profile.


| improve this answer | |
  • This answer gave me the solution while the accepted one did not. – Javier Feb 26 at 16:24

Adding the following to .tmux.conf:

set-option -g default-shell "/bin/bash"

DOES NOT yield the desired result.

Only when adding source "$HOME/.bashrc" to ~/.bash_profile the intended result is achieved.

This will work on an active tmux session when opening a new window or pane, and also when detaching and opening a new tmux session.

Tested on:

VERSION="16.04.2 LTS (Xenial Xerus)"
tmux 2.1
| improve this answer | |

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.