view new_slide.sh @ 7:e0c4a349c94f

Copy template when generate new slide
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Fri, 31 Jan 2014 14:10:07 +0900
parents f6d65d2a806f
children 213c5de5d47d
line wrap: on
line source

#!/bin/sh

# import definitions
. `dirname $0`/config/definition.sh

# function

dirname_from_day_of_the_week() {

    case $1 in
        "mon") week_of_day="next Mon." ;;
        "tue") week_of_day="next Tue." ;;
        "wed") week_of_day="next Wed." ;;
        "thu") week_of_day="next Thu." ;;
        "fri") week_of_day="next Fri." ;;
        "sat") week_of_day="next Sat." ;;
        "sun") week_of_day="next Sun." ;;

        *) week_of_day=""   # default is empty value, it's today
    esac

    if [[  $(uname) == Darwin ]]; then
        command="gdate"     # --date option is supported by GNU date
    else
        command="date"
    fi

    ${command} --date="${week_of_day}" +"${slide_date_format}"
}

# main

slide_dirname=`dirname_from_day_of_the_week ${1}`
dir_full_path="${slide_root_dirname}/${slide_dirname}"
slide_full_path="${dir_full_path}/${slide_name}"

mkdir -p ${dir_full_path}
if !([ -f ${slide_full_path} ];) then
    cp ${slide_template_file} ${slide_full_path}
fi
echo ${slide_full_path}