File README.md changed (mode: 100644) (index f266be6..71782a4) |
... |
... |
Look at the top comments inside scripts. |
19 |
19 |
|
|
20 |
20 |
| Script | Description |
| Script | Description |
21 |
21 |
| ------------------------ | ----------- |
| ------------------------ | ----------- |
|
22 |
|
| envis-diff | Improved highlighting of whitespace in diff |
22 |
23 |
| gifrec | Handy script to record interaction as a GIF |
| gifrec | Handy script to record interaction as a GIF |
23 |
24 |
| gt-clean-merged-branches | Interactive deletion of old branches in a Git repo |
| gt-clean-merged-branches | Interactive deletion of old branches in a Git repo |
24 |
25 |
|
|
File envis-diff added (mode: 100755) (index 0000000..dde2126) |
|
1 |
|
#!/bin/bash |
|
2 |
|
# Copyright 2020 xaizek <xaizek@posteo.net> |
|
3 |
|
# |
|
4 |
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
|
# you may not use this file except in compliance with the License. |
|
6 |
|
# You may obtain a copy of the License at |
|
7 |
|
# |
|
8 |
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
|
# |
|
10 |
|
# Unless required by applicable law or agreed to in writing, software |
|
11 |
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
|
# See the License for the specific language governing permissions and |
|
14 |
|
# limitations under the License. |
|
15 |
|
|
|
16 |
|
# This script makes whitespace changes more prominent in diffs. |
|
17 |
|
# Compared to standard git-diff both "-" and "+" lines are highlighted. |
|
18 |
|
# Two specific cases are handled here: |
|
19 |
|
# * highlighting of trailing whitespace in diffs in purple; |
|
20 |
|
# * making tabulation character visible. |
|
21 |
|
|
|
22 |
|
# Usage in git: git config --global core.pager envis-diff |
|
23 |
|
|
|
24 |
|
# Related post: https://reversed.top/2014-06-22/make-tabs-visible-in-git-diff/ |
|
25 |
|
|
|
26 |
|
# TODO: make it work better with diff-so-fancy |
|
27 |
|
# (https://github.com/so-fancy/diff-so-fancy) |
|
28 |
|
# there were issues with trailing whitespace highlighting |
|
29 |
|
|
|
30 |
|
sed -e 's/^\(\x1b\[[0-9]\+m\)*\s\x1b\[m$/ /' \ |
|
31 |
|
-e '/^\(\x1b\[[0-9]\+m\)*[-+].*\s\+\x1b\[m$/ { |
|
32 |
|
# insert marker before trailing whitespace |
|
33 |
|
s/ \+\x1b\[m$/\x01&/ |
|
34 |
|
# boil out if there is no trailing whitespace |
|
35 |
|
T end |
|
36 |
|
# copy line to hold space |
|
37 |
|
h |
|
38 |
|
# remove marker and anything after it |
|
39 |
|
s/\x01.*$// |
|
40 |
|
# exchange hold and pattern spaces |
|
41 |
|
x |
|
42 |
|
# replace marker and anything before it with escape sequence to |
|
43 |
|
# highlight trailing whitespace using bold red background |
|
44 |
|
s/.*\x01/\x1b[35;47;7m/ |
|
45 |
|
# alternative: use middledot character and no highlight |
|
46 |
|
# s/.*\x01// |
|
47 |
|
# y/ /·/ |
|
48 |
|
# append result to line prefix |
|
49 |
|
H |
|
50 |
|
# exchange to get full line in pattern space |
|
51 |
|
x |
|
52 |
|
# remove newlines created by "H" command |
|
53 |
|
s/\n// |
|
54 |
|
|
|
55 |
|
:end |
|
56 |
|
# apply tab transformation as second pattern is skipped if this one |
|
57 |
|
# matches |
|
58 |
|
s/\t/. /g |
|
59 |
|
}' \ |
|
60 |
|
-e 's/\t/. /g' \ |
|
61 |
|
| exec less -R |