-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgithub-build-bin-readme
executable file
·62 lines (50 loc) · 1.66 KB
/
github-build-bin-readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
#
# Build README.md in github.com/D630/bin.
cd -- /home/stow/bin/bin ||
exit 1
IFS=.: read -r _ _ p _ _ < <(exec -- git config --local --get remote.origin.url)
P=https://github.com/$p
export LC_ALL=C
__find() {
# find . -maxdepth 1 -regextype posix-egrep \
# \( -path "./.*" -o -name README.md \) \
# -prune \
# -o \( -type f -a -regex "\./.*\.(awk|py|sh)" \) \
# -exec grep -H -m 1 '^# ' {} +;
# git ls-files -z '*.awk' '*.py' '*.sh' \
# | xargs -0 grep -H -m 1 '^# ';
exec -- git ls-files -z '[!A][!R]*' |
exec -- xargs -0 -- grep -E -Z -l -m 1 '^#!.*(awk|[bdtm][ack]sh|python|sh|perl).*' |
command -- xargs -0 -- grep -H -m 1 '^# '
# find . -maxdepth 1 \
# \( -path "./.*" -o -name README.md \) \
# -prune \
# -o \( -type f -a -name "*.php" \) \
# -exec grep -H -m 1 '// ' {} + \
# | sed 's/ \/\//#/';
# git ls-files -z '*.php' \
# | xargs -0 grep -H -m 1 '// ' \
# | sed 's/ \/\//#/';
exec -- git ls-files -z '[!A][!R]*' |
exec -- xargs -0 -- grep -E -Z -l -m 1 '^#!.*php.*' |
exec -- xargs -0 -- grep -H -m 1 '// ' |
exec -- sed 's:[[:space:]]*//:#:'
}
{
header=$(</dev/fd/0)
} <<HEADER
Short scripts, which do not belong to my dotfiles. Unless otherwise stated,
these files are in the public domain.
List:
HEADER
__find |
exec -- sort |
{
printf %s\\n "$header"
while IFS=: read -r p c; do
printf '* [%s](%s/blob/master/%s): %s\n' \
"${p#./}" "$P" "${p#./}" "${c#\# }"
done
} >./README.md
# vim: set ft=zsh :