1

I would like to have a tmux pane where everytime I switch to it runs a command like git diff so that I automatically see the new version of the output.
Can this be done?

2 Answers 2

0

bind-key C-G select-pane -t 1 \; send-keys "git diff" ENTER

This relies on the pane being number 1. So, if you are doing some work in another pane, and you want to switch over and do this real quick, it will switch and run the command.

You could also simply send the command to the pane without needing to actively switch into it. But this is the closest thing to honoring your question that I can currently come up with.

Note: The capitalized ENTER at the end is important otherwise you simply end up with the git diff standing there.

0

I know this question was asked a lot of time ago but this could help the OP and eventual persons looking for a solution. I wrote a tmux addon showing, in tmux status bar, the status of the git working tree you're currently in. It is updated every time you run a command, (or just press ENTER at your shell prompt). In case you want to check it out: tmux-gitbar

Here's an example of what it does, where you see the status bar automatically updating the status bar with information about the Git working tree you're currently in.

Link to Tmux-GitBar GitHub Page

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .