css
javascript
html
python
makefile

new.sh 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. # Load data
  3. printf '%s' "Enter Title: "
  4. read -r
  5. title="$REPLY"
  6. printf '%s' "Enter Author: "
  7. read -r
  8. author="$REPLY"
  9. printf '%s' "Enter Category: "
  10. read -r
  11. category="$REPLY"
  12. # Slug | lowercase, without accent mark
  13. lug=$(printf '%s' "${title// /-}")
  14. slug=$(echo "$lug" | sed 'y/áÁàÀãÃâÂéÉêÊíÍóÓõÕôÔúÚñÑçÇ/aAaAaAaAeEeEiIoOoOoOuUnNcC/' | sed -e 's/\(.*\)/\L\1/')
  15. printf '%s' "Enter Tags: "
  16. read -r
  17. tag="$REPLY"
  18. # output
  19. o_author=$(printf '%s%s\n' "Author: " "$author")
  20. o_category=$(printf '%s%s\n' "Category: " "$category")
  21. o_date=$(printf '%s%s\n' "Date: " "$(date +"%Y-%m-%d %I:%M")")
  22. o_slug=$(printf '%s%s\n' "Slug: " "$slug")
  23. o_tag=$(printf '%s%s\n' "Tags: " "$tag")
  24. o_title=$(printf '%s%s\n' "Title: " "$title")
  25. # export to file.md
  26. printf '%s\n%s\n%s\n%s\n%s\n%s\n' "$o_author"\
  27. "$o_category"\
  28. "$o_date"\
  29. "$o_slug"\
  30. "$o_tag"\
  31. "$o_title" > "content/$slug.md"