Question

I did some updating on my Mac and seem to have broken some of my settings. I have the following set in my .bash_profile

export PS1="\W $"

This is working in my normal bash session to show just the current directory instead of the whole path. However, when I switch into tmux, it again displays the whole path. Other changes to the PS1 in the bash profile such as color or other characters work fine and are reflected in tmux. I have emptied out my .tmux.conf to see if that was causing conflict but there was no change to this behavior.

I did create a new user on the system and tried the same PS1 and it worked perfectly in both a normal session and tmux.

I am mostly confused because I know I had it working and can't figure out what would have changed in the update. What files besides .bash_profile and .tmux.conf could be at play here? Is there a way to tell where tmux is pulling it's settings from?

Additional info: This behavior is the same in both iTerm2 and Terminal Tmux version 1.8 Mac OSX 10.9.1

Was it helpful?

Solution

Add the following to your .tmux.conf:

new -n WindowName bash --login

You can replace WindowName with whatever you want the first window to be named. When bash is invoked this way, it sources to your .bash_profile, .bash_rc, .profile, etc. which is where you change your $PS1.

OTHER TIPS

This one works for me: In tmux/terminal:

tmux set-option -g default-command bash

Or simply put into ~/.tmux.conf:

set-option -g default-command bash

I have the similar problem. I get the correct result if I always start tmux with the bash command applied, like so:

tmux new bash

So, to simplify this, I just created an alias in my ~/.bash_aliases file, which I use all the time:

alias tn='tmux new bash'

This does only work for the first window though. When creating new windows, you have to start bash again, by executing bash in the terminal.

I had the same problem and after some research I have added the following command to my ~/.tmux.conf:

set-option -g default-command "reattach-to-user-namespace -l /opt/local/bin/bash --login"

I am using OSX 10.9.5 with iTerm2 Build 2.0.0.20141103, bash 4.3.30(1)-release, tmux 1.9a. Bash and tmux are from macports.

When using tmux with byobu, you can try the byobu-prompt command. It'will ask you whether you want a bash color prompt. After answering Yes, the prompt will change to the usual user@host.

Add the following line to ~/.tmux.conf

set -g default-terminal "screen-256color"

Add the following in your ~/.tmux.conf

set -g default-terminal "tmux-256color" 

From the beloved ArchWiki tmux

Better to detect which terminals are known to the system's terminfo database via the infocmp command. I've got the following in my ~/.tmux.conf:

# Last match wins
if-shell "infocmp xterm-256color" "set-option -g default-terminal xterm-256color"
if-shell "infocmp screen-256color" "set-option -g default-terminal screen-256color"
if-shell "infocmp tmux" "set-option -g default-terminal tmux"

If the infocmp shell-command succeeds, then the following set-option tmux command is executed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top