view new_slide.sh @ 6:f6d65d2a806f

Split const definitions into config/definition.sh
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Thu, 30 Jan 2014 22:08:04 +0900
parents ba844bcb8b5e
children e0c4a349c94f
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}
touch ${slide_full_path}
echo ${slide_full_path}