tildelog/lib/list_posts.sh

21 lines
531 B
Bash
Raw Normal View History

2020-12-19 19:43:21 +00:00
#!/usr/bin/env bash
# Displays a list of the posts
2021-02-10 20:48:40 +00:00
declare date_format
declare date_locale
2020-12-19 19:43:21 +00:00
list_posts() {
2021-02-10 20:48:40 +00:00
ls ./*.md &> /dev/null
(($? != 0)) &&
echo "No posts yet. Use '$0 post' to create one" &&
return
2020-12-19 19:43:21 +00:00
lines=""
n=1
while IFS='' read -r i; do
is_boilerplate_file "$i" && continue
line="$n # $(get_post_title "$i") # $(LC_ALL=$date_locale date -r "$i" +"$date_format")"
lines+=$line\\n
n=$(( n + 1 ))
2021-02-10 20:48:40 +00:00
done < <(ls -t ./*.md)
2020-12-19 19:43:21 +00:00
echo -e "$lines" | column -t -s "#"
}