joh / when-changed

Execute a command when a file is changed
Other
1.21k stars 107 forks source link

Not working with git log #83

Closed goldylucks closed 5 years ago

goldylucks commented 5 years ago

Thank you so much for this project!

Anything I'm doing wrong?

Peek 2019-08-04 20-27

The same command works with linux's built in watch:

Peek 2019-08-04 20-29

joh commented 5 years ago

Interesting use case! By default, .git directories are ignored by when-changed. See https://github.com/joh/when-changed/blob/master/whenchanged/whenchanged.py#L53 You can comment out that line and it should work.

goldylucks commented 5 years ago

Thanks for the response!

I commented that line out, restarted gnome, opened a fresh terminal, and still doesn't work :/

any other ideas we can try?

joh commented 5 years ago

Hmm, it works for me here. Did you remember to install your modified version with pip install .?

Btw, to run git log whenever you change branches it might be better to watch .git/HEAD...

goldylucks commented 5 years ago

Hmm, it works for me here

So now it only refreshes if I focus on the terminal and press q. For you it refreshes automatically when you change a branch or add a commit?

I can't get that to work :/

Do you have a vid/gif showing it in action? to make sure we are talking about the same behavior here.

joh commented 5 years ago

Ah, your git log is probably waiting for pager input. Try with git --no-pager log instead.

goldylucks commented 5 years ago

ok that works, thanks for pointing that out! now I'm seeing many "re-renders" of git log when I make a change:

whe-changed

TBH, working with watch is fine by me, just would be nice to not poll if I can listen to changes, but don't sweat about it, so feel free to close this issue.

my idea might be a very edgy use case

joh commented 5 years ago

You could try the -1 option. Also maybe use clear && git --no-pager log as the command.