Last active
May 17, 2024 23:58
-
-
Save ryo-n/e8c1cbdd9bc20416fc9ed3ee85c676a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Mac用 | |
# brew install coreutils してgdateを使う | |
# 開始日を今日の日付に設定 | |
start_date=$(gdate +"%Y%m%d") | |
# 開始日を前日に設定 | |
start_date=$(gdate -d "$start_date -1 day" +"%Y%m%d") | |
# 開始日を変数に設定 | |
current_date=$(gdate -d "$start_date" +"%Y%m%d") | |
# 何日分遡るかを設定 | |
days_to_go_back=30 | |
for ((i=0; i<days_to_go_back; i++)); do | |
# 現在の日付の曜日を取得(0: 日曜日, 1: 月曜日, ..., 6: 土曜日) | |
day_of_week=$(gdate -d "$current_date" +%u) | |
# 曜日が火曜日(2), 水曜日(3), 木曜日(4)のときのみ表示 | |
if [[ $day_of_week -eq 2 || $day_of_week -eq 3 || $day_of_week -eq 4 ]]; then | |
for j in $(seq 3 -1 1); do | |
dir_name="adt_all_${current_date}_${j}" | |
if [ ! -d "$dir_name" ]; then | |
echo $dir_name | |
# cargo compete、VSCodeを使っている場合の例 | |
# | |
# cargo compete new $dir_name | |
# code $dir_name | |
# open https://atcoder.jp/contests/$dir_name/tasks | |
exit 0 | |
fi | |
done | |
fi | |
# 1日前の日付を計算 | |
current_date=$(gdate -d "$current_date -1 day" +"%Y%m%d") | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment