view new_slide.sh @ 163:b8e16c48a5a4 default tip

Update template
author atton <atton@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2017 17:18:41 +0900
parents 62d6bd64af0a
children
line wrap: on
line source

#!/bin/sh

cd $(dirname $0)

# import definitions
. 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}