erikw / tmux-powerline

A hackable statusbar for tmux consisting of dynamic & beautiful looking segments, inspired by vim-powerline, written purely in bash.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VCS info not updating

ajpaulson opened this issue · comments

Running in Debian.

If I start tmux from within a git/hg/svn repo it shows the vcs info and if I switch branches in that repo it updates...
But if I change directory it still displays the vcs info for the directory I was in before starting tmux and if I started from a non-version controlled directory it never shows up.

quick edit

running the vcsinfo script via bash -x gives the correct output for whichever directory I'm in.

I use zsh with robbyrussel's oh-my-zsh

I do have bash >4.2 installed and added the PS1 line in the README to the bashrc

I don't use zsh my self but I guess it does not read ~/.bashrc by default. Try putting that stuff in your ~/.zshrc. Does that work?

The thing is I have an extremely modified prompt already in Zsh - I'm not sure how adding that to the zshrc may affect it.

I did try changing shell to bash to see if that was simply the issue but I still get the same problem. - I don't think the PS ! line is the issue. I have also tried in different terminal emulators (I use urxvt as my main one) and again I have the same problem.

Well give it a try. That line should preserve the existing changes so put it after the oh-my-zsh stuff how ever that works. I use urxvt as well. Try it in a clean environment with no bashrc (except the line needed for VCS stuff).

I use zsh 5.0 and the following correctly added the vcs info to the prompt:

PROMPT="$PROMPT"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")'

If you add this to the very bottom of your rc-file, it should have no negative affect on your prompt. Using PS1 should also have the same affect since both are linked to the same variable.

Did you get it to work @ajpaulson?

I've been under some tight deadlines at work so I've not had a chance to test yet - I will update once I've tested.

@erikw I had exactly the same issue and I can confirm that @scicalculator's suggestion fixed it for me. Maybe clarify the README with those instructions?

I believe zsh recognizes PS1 as well. But I don't know if PROMPT and PS1 refers to the same variable. Does it work to put the PS1-line from the README in the ~/.zshrc?

Yup. Would be useful to add to the README to put it in to ~/.zshrc, not quite sure where I was trying to put it at first but it has to be at the bottom of that file.

I just cygwin'd zsh and PROMPT seems to be the same thing as PS1. Can you verify that what solves this issue is to use the same line as in the README but appending it to ~/.zshrc instead of ~/.bashrc?

I can confirm that for me (zsh 5.0) the line as copied from the README works unmodified. The same should also be true for most versions of zsh 4.x (hopefully no one is on earlier versions, for their sake).

@Olliea95 I suspect that you had accidentally put the line too early and then re-wrote PS1 afterwards. It is certainly convenient to put this line at the very bottom, but if you compartmentalize your rc-file then you could put all prompt customization together with this line near-or-at the bottom of that section.

This will work

# will work PS1 will be '$ '
PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")'
PS1='$ '$PS1

This will fail

# will NOT work PS1 will be '$ '
PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")'
PS1='$ '

Alright a3fa89c and I mark this as solved :-)