12345678910111213141516171819202122232425262728293031 |
- #!/bin/bash
- function set_today
- {
- local today_path="$(date +%Y)/$(date +%m)/$(date +%d)/"
- # If the folder doesn't exist, then create it.
- if [[ ! -d $today_path ]]; then
- mkdir -p "$today_path"
- fi
- if [[ -a Today ]]; then
- local today_link=$(stat -c %N Today | sed -n -e "s/.* -> '\(.*\)'/\1/p")
- # Is the Today symlink already pointing to todays folder?
- if [[ $today_path == $today_link ]]; then
- echo "Already today!";
- return 0
- fi
- # Copy all unfinished tasks to today.
- if [[ -n $(ls Today/ | grep -G '.*\.description$') ]]; then
- cp -P Today/*.description "$today_path"
- fi
- unlink Today
- fi
- # Update the symlink
- ln -s "$today_path" Today
- }
|