Second Brain: Crafted, Curated, Connected, Compounded on 10月02日
使用脚本记录书籍写作进度
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了一种通过脚本记录书籍写作进度的方法,通过git日志和Markdown文件计数实现。

To document the progress of my book writing, I created a little script that outputs words written over time.

Markdown files in my Obsidian Vault:

1
find ~/Simon/Sync/SecondBrain -type f -name "*.md" | wc -l

or another one:

1
find src -type f -not -path '*/\.*' -name '*.md' -exec cat {} \; | wc -w

Explanation:

    find /path/to/your/obsidian/vault: Searches the specified directory.-type f: Ensures that only files are considered (not directories).-name "*.md": Filters the search to only include files with the .md extension.| wc -l: Counts the number of lines output by the find command, which corresponds to the number of Markdown files.

# Data Views

.

# Over time with git (DEDP book)

Interesting is to count the words over time. As I have everything in git, I loop over git logs with this script words-history.sh:

 1 2 3 4 5 6 7 8 9101112131415161718192021
#!/bin/bashlast_count=0# Iterate over each commitgit log --reverse --pretty=format:"%H %ad" --date=short | while read hash date; do    # Check out the commit    git checkout $hash &> /dev/null    # Count the words in markdown files    words=$(find src -type f -not -path '*/\.*' -name '*.md' -exec cat {} + | wc -w)        # Compare with the last count and output only if different    if [ "$words" -ne "$last_count" ]; then        echo "$date,$words"        last_count=$words    fidone# Check out the original branchgit checkout main

Now I can run below in my Makefile:

1
./words-history.sh > stats/stats-words.csv

With Rill Developer, I imported and created CSV and made a dashboard with

Simple is beauty.


Origin:
References: Markdown
Created 2023-11-09

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

书籍写作 脚本记录 Git日志 Markdown文件
相关文章