grep
grep

Reputation: 4026

.tmux.conf: update status commands on panel focus

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.. ?

Upvotes: 5

Views: 1845

Answers (2)

Nathan Kot
Nathan Kot

Reputation: 2432

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)'

Upvotes: 4

Anya Shenanigans
Anya Shenanigans

Reputation: 94739

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.

Upvotes: 1

Related Questions