diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-08-20 19:29:51 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-08-20 19:29:51 +0200 |
commit | 03448087617fcce47570007cdaf7d8ccc5f8e846 (patch) | |
tree | c26f65a0a276734a913b204e328555a3c91a5c54 | |
parent | 924e217ef7a54ae4eda4b9696d97e9f2846d67cc (diff) | |
download | dotfiles-03448087617fcce47570007cdaf7d8ccc5f8e846.tar.gz dotfiles-03448087617fcce47570007cdaf7d8ccc5f8e846.tar.xz dotfiles-03448087617fcce47570007cdaf7d8ccc5f8e846.zip |
Git config: make subdiff-related commands work well
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r-- | .gitconfig | 22 | ||||
-rwxr-xr-x | .local/bin/subdiff | 24 |
2 files changed, 37 insertions, 9 deletions
@@ -7,10 +7,24 @@ dh = diff HEAD wd = diff --word-diff swd = show --word-diff - pd = !git diff --color | subdiff | ${PAGER} - ps = !git show --color | subdiff | ${PAGER} - # script to preserve colors - s = !script -c 'git status' /dev/null | grep -ve '^. [(]' -e '^..$' | awk '/^[\"-$] Untracked/{exit}{print $0}' + pd = "!git_pd() {\ + git diff --color \"$@\" | subdiff | ${PAGER};\ + }; git_pd" + pwd = "!git_pwd() {\ + git wd --color \"$@\" | subdiff | ${PAGER};\ + }; git_pwd" + ps = "!git_ps() {\ + git show --color \"$@\" | subdiff | ${PAGER};\ + }; git_ps" + pswd = "!git_pswd() {\ + git swd --color \"$@\" | subdiff | ${PAGER};\ + }; git_pswd" + # script to preserve colors; quoting is strange, but "just works" + s = "!git_s() {\ + script -c \"git status \"$@\"\" /dev/null\ + | grep -ve '^. [(]' -e '^..$'\ + | awk '/^[\"-$] Untracked/{exit}{print $0}';\ + }; git_s" [core] editor = vim diff --git a/.local/bin/subdiff b/.local/bin/subdiff index 6bc7db3..92a3a78 100755 --- a/.local/bin/subdiff +++ b/.local/bin/subdiff @@ -1,6 +1,20 @@ #!/bin/bash -sed \ - -e 's|^\(\x1b\[[0-9;]\+m\)\?+\(\x1b\[m\x1b\[[0-9;]\+m\)\?+|\x1b\[1;36m++|g' \ - -e 's|^\(\x1b\[[0-9;]\+m\)\?+\(\x1b\[m\x1b\[[0-9;]\+m\)\?-|\x1b\[1;35m+-|g' \ - -e 's|^\(\x1b\[[0-9;]\+m\)\?-+|\x1b\[36m-+|g' \ - -e 's|^\(\x1b\[[0-9;]\+m\)\?--|\x1b\[35m--|g' + +# should also work reasonably well with git diff --word-diff + +sed -n \ + -e ":start" \ + -e "/^\(\x1b\[[0-9;]\+m\)\?diff .*patch\(\(\x1b\[m\)\?$\| \)/bpatch" \ + -e "p;n" \ + -e "#s|.*|NONPATCH|" \ + -e "bstart" \ + -e ":patch" \ + -e "p;n" \ + -e "/^\(\x1b\[[0-9;]\+m\)\?diff /bstart" \ + -e "/^\(\x1b\[[0-9;]\+m\)\?\([-+]\)\2\2 /bpatch" \ + -e "#s|.*|PATCH|" \ + -e 's|^\(\x1b\[[0-9;]\+m\)\([{]\?[+]\)\(\x1b\[m\1\)\?[+]|\x1b\[1;36m\2+|' \ + -e 's|^\(\x1b\[[0-9;]\+m\)\([{]\?[+]\)\(\x1b\[m\1\)\?[-]|\x1b\[1;35m\2-|' \ + -e 's|^\(\x1b\[[0-9;]\+m\)\([[]\?[-]\)\(\x1b\[m\1\)\?[+]|\x1b\[36m\2+|' \ + -e 's|^\(\x1b\[[0-9;]\+m\)\([[]\?[-]\)\(\x1b\[m\1\)\?[-]|\x1b\[35m\2-|' \ + -e "bpatch" |