#!/usr/bin/fish set SLIDE_NUM $argv[1] set SLIDE_NAME $argv[2] set SLIDE_TITLE $argv[3] set SLIDE_NAME_MARK 'TEMPLATE_NAME' set SLIDE_TITLE_MARK 'TEMPLATE_TITLE' set SLIDES_PATH "../godot/slides" set TEMPLATE_FOLDER "$SLIDES_PATH/template" set TEMPLATE_FILE "$TEMPLATE_FOLDER/$SLIDE_NAME_MARK.tscn" set SLIDE_FOLDER "$SLIDES_PATH/$SLIDE_NUM" set SLIDE_FILE "$SLIDE_FOLDER/$SLIDE_NAME.tscn" function gen-res-id echo (head -n 10 /dev/urandom | tr -dc 'a-z' | string shorten -m $argv[1] --char="") end set IDS_MARK 'aaaaa' 'bbbbb' 'ccccc' 'uuuuuuuuuuuuu' echo "Read $TEMPLATE_FILE" set CONTENT (cat $TEMPLATE_FILE) function get-content printf %s\n $CONTENT end echo "Rename template : $SLIDE_NAME_MARK -> $SLIDE_NAME" set CONTENT (get-content | sed -e "s/$SLIDE_NAME_MARK/$SLIDE_NAME/") echo "Set title : $SLIDE_TITLE_MARK -> $SLIDE_TITLE" set CONTENT (get-content | sed -e "s/$SLIDE_TITLE_MARK/$SLIDE_TITLE/") echo "Replace marks" for k in (seq (count $IDS_MARK)) set NEW_ID (gen-res-id (string length $IDS_MARK[$k])) echo $k ':' $IDS_MARK[$k] '->' $NEW_ID set CONTENT (get-content | sed -e "s/$IDS_MARK[$k]/$NEW_ID/") end echo "Write to : $SLIDE_FILE" mkdir --parents $SLIDE_FOLDER get-content > $SLIDE_FILE