5 ms·
I use a modified version of mislav's git prompt https://gist.github.com/mislav/1712320 https://gist.github.com/mislav/1712320 which is pretty minimal but usuall
by an_ko 11y ago
I use a modified version of mislav's git prompt https://gist.github.com/mislav/1712320 https://gist.github.com/mislav/1712320 which is pretty minimal but usually enough for me.
For when I have to wrangle lots of files at once (like during interactive rebase to clean up history before push) I have a git watch alias that shows a high-level overview of changes that refreshes with inotify:
[alias]
watch = "!clear;inotifywait --quiet -mr -e modify,move,create,delete --format \"%f %e\" @/.git . | \
while read file; do \
clear;\
git status --short;\
git --no-pager diff --shortstat;\
done;"
I leave that running in a visible terminal window. It's more verbose than a prompt and reduces the need for constant git status sanity-checking. Maybe useful for someone.
- TheRealWatson 11y agoI'm going to steal this, thanks. I'll probably make it a script file instead of an alias, though.
- couchand 11y agoPost the Gist when you're done, please?
- mendelk 11y agoHow would this need to be changed to work on osx?
- ianlevesque 11y agoJust need to replace inotifywait with an FSEvents-based change watcher.
- sulam 11y agowatchman (https://github.com/facebook/watchman https://github.com/facebook/watchman) is cross platform.
- _djo_ 11y agoIt's less efficient, but you could just use a timed solution like watch: watch -n 2 'git status --short; git --no-pager diff --shortstat;'
- bm1362 11y agoThis works on OSX: while :; do clear; git status --short; git --no-pager diff --shortstat; sleep 2; done
- gknoy 11y agoI like your `git watch` alias! That's very slick. I like my git prompt to show me my branch name, colored with grey (no changes), red (unsaved changes), or green (staged changes), with the depth of the branch, e.g.: gknoy@host:~/dev/foo/[bar-feature:4]$ My prompt is based on: https://gist.github.com/tobiassjosten/828432 https://gist.github.com/tobiassjosten/828432 ... but I've made slight modifications: # I sometimes have very long branch names. # I don't assume it's a hash: if [ ${#GIT_BRANCH} -gt 40 ]; then # GIT_BRANCH="(no branch)" GIT_BRANCH="${GIT_BRANCH:0:40}..." fi and, at the end of `git_prompt`: branch_depth=`git rev-list HEAD --not --remotes|wc -l` echo "[$git_color$GIT_BRANCH$c_reset:${branch_depth}]"
- agumonkey 11y agoOn my machine (archlinux, xterm) it flickers, as if there was a loop. Anybody sees the same ?
- an_ko 11y agoIf you add an echo "$file" inside the while loop, what do you see? I deliberately set the .git directory to be ignored (using @) to avoid tons of repeating when the index.lock file is repeatedly recreated. Maybe that's what's going on here.
- an_ko 11y agoI was missing a dot before /.git and can't edit the parent anymore… It should read [alias] watch = "!clear;inotifywait --quiet -mr -e modify,move,create,delete --format \"%f %e\" @./.git . | \ while read file; do \ clear;\ git status --short;\ git --no-pager diff --shortstat;\ done;" Sorry!