代码拉取完成,页面将自动刷新
#!/usr/bin/env bash
getTitle() {
PATHMD=$1
head -n 3 "${PATHMD}" | awk '/^# / {$1=""; print substr($0,2); exit;}'
}
genDir() {
Dir=$1
for PATHMD in $(find $Dir -name "*.md" -exec ./.parent_dirs.sh {} \; | sort -n | uniq); do
# remove tailing slash for dir
PATHMD=${PATHMD%/}
# README.md & index.md belongs to current folder
NAMEMD=${PATHMD##*/}
if [[ ${NAMEMD} =~ README.*md || ${NAMEMD} == "index.md" || ${NAMEMD} == "SUMMARY.md" ]]; then
continue
fi
# ignore .
if [[ ${PATHMD} == "." ]]; then
continue
fi
# count indentation # $PATHMD = ./miao/wang/x.md
TMP1=${PATHMD#./} # TMP1 = miao/wang/x.md
TMP2=${TMP1//[^\/]} # TMP2 = //
INDENT=${#TMP2} # INDENT = 2
for (( i=0; i<${INDENT}; i++ )); do
echo -n " "
done
if [[ -f ${PATHMD} ]]; then
TITLE=$(getTitle "${PATHMD}")
if [[ -n ${TITLE} ]]; then
echo "* [${TITLE}](${PATHMD})"
else
echo "* [${NAMEMD}](${PATHMD})"
fi
elif [[ -f ${PATHMD}/index.md ]]; then
TITLE=$(getTitle "${PATHMD}/index.md")
if [[ -n ${TITLE} ]]; then
echo "* [${TITLE}](${PATHMD}/index.md)"
else
echo "* [${NAMEMD}/](${PATHMD}/index.md)"
fi
elif [[ -f ${PATHMD}/README.md ]]; then
TITLE=$(getTitle "${PATHMD}/README.md")
if [[ -n ${TITLE} ]]; then
echo "* [${TITLE}](${PATHMD}/README.md)"
else
echo "* [${NAMEMD}/](${PATHMD}/README.md)"
fi
elif [[ -d ${PATHMD} ]]; then
echo "* [${NAMEMD}/]()"
else
echo "* [${NAMEMD}]()"
fi
done
}
echo "# Summary"
echo
echo "# 🏠主页"
echo
echo "* [📔README.md](./README.md)"
echo
echo "# 🌏全局配置"
echo
echo "* [config.nix](./config.nix.md)"
echo "* [TODO: nix/nix.conf](./nix/nix.conf.md)"
echo "* [opt.nix](./opt.nix.md)"
echo
echo "# 🖥️系统配置(需sudo,用于NixOS)"
echo
echo "* [system.nix](./system.nix.md)"
genDir ./sys/
echo
echo "# 😺用户配置(无需sudo,用于Nix/NixOS)"
echo
echo "* [home.nix](./home.nix.md)"
genDir ./usr/
echo
echo "# 🤖安卓配置(无需sudo,复用\"用户配置\")"
echo
echo "* [nix-on-droid.nix](./nix-on-droid.nix.md)"
echo
echo "# 🔩通用模块"
echo
genDir ./modules/
echo
echo "# 📝文档和心得体会"
echo
genDir ./docs/
echo
echo "# 📃Nix脚本(nix-shell和打包)"
echo
genDir ./scripts/
echo
echo "# 📌其他"
echo
echo "* [shell.nix](./shell.nix.md)"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。