Last active
March 12, 2018 17:31
-
-
Save aryelgois/c413ca5bf7bb9341c3c9181d492217d6 to your computer and use it in GitHub Desktop.
Fix git colors for watch(1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Fix git colors, userful for watch(1) | |
# | |
# @usage watch -c 'git colored <git command>' | |
# @see https://askubuntu.com/questions/967503 for an example of the problem and explanation | |
# run git command and replace all foreground colors to include '0' | |
exec git -c color.ui=always "$@" | sed -r $'s/\033\[([[:digit:]][[:digit:]])m/\033\[0;\\1m/g; s/\033\[m/\033\[0m/g' |
My favorite usage:
watch -c 'git colored log -1; echo; git colored log --all --date-order --decorate --graph --oneline'
I aliased this in ~/.gitconfig:
[alias]
watch = !watch -c 'git colored log -1 && echo && git colored log --all --date-order --decorate --graph --oneline'
note the
&&
replacing;
Simply keep a terminal running git watch
inside your repository
the next step is making watch(1) scrollable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install
cp git-colored.sh ~/bin/git-colored
or you can symlink, if you like to keep repositories around.