forked from lujun9972/emacs-document
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_index.sh
executable file
·37 lines (32 loc) · 1.04 KB
/
generate_index.sh
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
#!/bin/bash
declare -A catalog_comment_dict
catalog_comment_dict=([calc]="关于Cacl的内容" [elisp-common]="关于elisp的内容" [org-mode]="关于org-mode的内容" [emacs-common]="其他未分类的emacs内容" [raw]="未翻译或者翻译到一半的内容" [reddit]="reddit好问题" [Eshell]="Eshell之野望")
catalogs=$(for catalog in ${!catalog_comment_dict[*]};do
echo $catalog
done |sort)
function generate_headline()
{
local catalog=$1
echo "* " $catalog
echo ${catalog_comment_dict[$catalog]}
echo
generate_links $catalog |sort -t "<" -k2 -r
}
function generate_links()
{
local catalog=$1
posts=$(ls -t $catalog)
old_ifs=$IFS
IFS="
"
for post in $posts
do
modify_date=$(git log --date=short --pretty=format:"%cd" -n 1 $catalog/$post) # 去除日期前的空格
echo "+ [[https://github.com/lujun9972/emacs-document/blob/master/$catalog/$post][$post]] <$modify_date>"
done
IFS=$old_ifs
}
for catalog in $catalogs
do
generate_headline $catalog
done