diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-10-14 19:03:03 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-10-14 19:35:03 +0200 |
commit | dfa324280f621a287d146282ad3c32edc30648ff (patch) | |
tree | ba01eb92018eeb80198bbf1fad0c82d77245c791 | |
parent | ac8ad37e9cec7b05f0f466ea10a2a052b9eb3d17 (diff) | |
download | dotfiles-dfa324280f621a287d146282ad3c32edc30648ff.tar.gz dotfiles-dfa324280f621a287d146282ad3c32edc30648ff.tar.xz dotfiles-dfa324280f621a287d146282ad3c32edc30648ff.zip |
bash: even " [+-]" at subdiff has a use case: patch-suggested-changes
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r-- | .bashrc | 2 | ||||
-rw-r--r-- | .bashrc-work | 20 | ||||
-rwxr-xr-x | .local/bin/subdiff | 10 |
3 files changed, 27 insertions, 5 deletions
@@ -19,7 +19,7 @@ _linkalias () { linkalias () { alias "$1=_linkalias $2"; } # Source the other common definitions -for f in /etc/bashrc ~/.bashrc-dotfiles ~/.bashrc-fedora ~/.bashrc-priv; do +for f in /etc/bashrc ~/.bashrc-dotfiles ~/.bashrc-fedora ~/.bashrc-work ~/.bashrc-priv; do [ -f "${f}" ] && source "${f}" || : done diff --git a/.bashrc-work b/.bashrc-work new file mode 100644 index 0000000..3fc6b75 --- /dev/null +++ b/.bashrc-work @@ -0,0 +1,20 @@ +# .bashrc-work + +patch-suggested-change() { + [ $# -ne 1 ] && int-usage "rej-file" && return + local origfile=${1%.rej} + { echo "diff ${origfile}.patch ${origfile}.patch.orig"; colordiff -du \ + <(diff -du \ + "${origfile}" \ + <(wiggle --merge "${origfile}" "${origfile}.rej") \ + | tail -n+3) \ + <(tail -n+3 "${origfile}.rej") + } | sed '2,4d;' | subdiff + #} | subdiff | tail -n+5 +} + +patch-suggested-changes() { + for f in $(find -name '*.rej'); do + patch-suggested-change "${f}" + done +} diff --git a/.local/bin/subdiff b/.local/bin/subdiff index 92a3a78..48b4343 100755 --- a/.local/bin/subdiff +++ b/.local/bin/subdiff @@ -13,8 +13,10 @@ sed -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 '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 '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" |