Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.tmux.conf: update status commands on panel focus

Tags:

git

bash

shell

tmux

I have a line in my .tmux.conf which simply shows me the git branch I am on.

set -g status-right ' #[bg=colour33] Branch #[(git branch)] '

When working in tmux, I regularly have panels in different directories. So my question becomes, is there a way to have the status command re-execute based on my "panel's cwd", instead of what it is doing now, where it seems to just hold onto the directory I was in when tmux was first opened.. ?

like image 393
grep Avatar asked Oct 16 '12 19:10

grep


2 Answers

In newer versions of tmux, you can use pane_current_path to achieve this:

set -g status-right '#(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD)'
like image 144
Nathan Kot Avatar answered Oct 19 '22 14:10

Nathan Kot


See this answer - Pane Title in Tmux - you would probably need to override the chpwd function which is invoked whenever you change working directories in bash/zsh.

like image 35
Petesh Avatar answered Oct 19 '22 14:10

Petesh