gd-slide.fish 993 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/fish
  2. set SLIDE_NUM $argv[1]
  3. set SLIDE_NAME $argv[2]
  4. set SLIDE_TITLE $argv[3]
  5. set SLIDE_NAME_MARK 'TEMPLATE_NAME'
  6. set SLIDE_TITLE_MARK 'TEMPLATE_TITLE'
  7. set SLIDES_PATH "../godot/slides"
  8. set TEMPLATE_FOLDER "$SLIDES_PATH/template"
  9. set TEMPLATE_FILE "$TEMPLATE_FOLDER/$SLIDE_NAME_MARK.tscn"
  10. set SLIDE_FOLDER "$SLIDES_PATH/$SLIDE_NUM"
  11. set SLIDE_FILE "$SLIDE_FOLDER/$SLIDE_NAME"
  12. function gen-res-id
  13. echo (head -n 10 /dev/urandom | tr -dc 'a-z' | string shorten -m 5 --char="")
  14. end
  15. set IDS (gen-res-id) (gen-res-id) (gen-res-id)
  16. set IDS_MARK 'aaaaa' 'bbbbb' 'ccccc'
  17. echo "Read $TEMPLATE_FILE"
  18. set CONTENT (cat $TEMPLATE_FILE)
  19. function get-content
  20. printf %s\n $CONTENT
  21. end
  22. echo "Rename template : $SLIDE_NAME_MARK -> $SLIDE_NAME"
  23. set CONTENT (get-content | sed -e "s/$SLIDE_NAME_MARK/$SLIDE_NAME/")
  24. echo "Set title : $SLIDE_TITLE_MARK -> $SLIDE_TITLE"
  25. echo "Replace marks"
  26. for k in (seq 3)
  27. echo $k ':' $IDS_MARK[$k] '->' $IDS[$k]
  28. end
  29. echo "Write to : $SLIDE_FILE"
  30. get-content