view new_slide.sh @ 8:213c5de5d47d

Fix path for new slide template
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Fri, 31 Jan 2014 17:48:56 +0900
parents e0c4a349c94f
children 62d6bd64af0a
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="`dirname $0`/${slide_root_dirname}/${slide_dirname}"
slide_full_path="${dir_full_path}/${slide_name}"
template_full_path="`dirname $0`/${slide_template_file}"

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