xaizek / xscripts (License: Apache-2.0) (since 2020-06-28)
Small collection of some scripts I find useful.
<root> / envis-diff (dde212688756f78c9c6c738d2ff13d8deac37afe) (2,337B) (mode 100755) [raw]
#!/bin/bash
# Copyright 2020 xaizek <xaizek@posteo.net>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script makes whitespace changes more prominent in diffs.
# Compared to standard git-diff both "-" and "+" lines are highlighted.
# Two specific cases are handled here:
#  * highlighting of trailing whitespace in diffs in purple;
#  * making tabulation character visible.

# Usage in git: git config --global core.pager envis-diff

# Related post: https://reversed.top/2014-06-22/make-tabs-visible-in-git-diff/

# TODO: make it work better with diff-so-fancy 
#       (https://github.com/so-fancy/diff-so-fancy)
#       there were issues with trailing whitespace highlighting

sed -e 's/^\(\x1b\[[0-9]\+m\)*\s\x1b\[m$/ /' \
    -e '/^\(\x1b\[[0-9]\+m\)*[-+].*\s\+\x1b\[m$/ {
            # insert marker before trailing whitespace
            s/ \+\x1b\[m$/\x01&/
            # boil out if there is no trailing whitespace
            T end
            # copy line to hold space
            h
            # remove marker and anything after it
            s/\x01.*$//
            # exchange hold and pattern spaces
            x
            # replace marker and anything before it with escape sequence to
            # highlight trailing whitespace using bold red background
            s/.*\x01/\x1b[35;47;7m/
            # alternative: use middledot character and no highlight
            # s/.*\x01//
            # y/ /·/
            # append result to line prefix
            H
            # exchange to get full line in pattern space
            x
            # remove newlines created by "H" command
            s/\n//

          :end
            # apply tab transformation as second pattern is skipped if this one
            # matches
            s/\t/.       /g
        }' \
    -e 's/\t/.       /g' \
    | exec less -R
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/xscripts

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/xscripts

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master