aboutsummaryrefslogtreecommitdiff
path: root/aoc
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-11-29 13:44:34 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-11-29 13:44:34 +0100
commit3b21e702c44d8f721e9ced997c417481f2c273ca (patch)
tree7423e230e1e9715e469b5a9a53259d74eb081bee /aoc
parent3fe83c0f2f7e6e3d87ede77607cca5922fa02a60 (diff)
downloadscripts-3b21e702c44d8f721e9ced997c417481f2c273ca.tar.gz
scripts-3b21e702c44d8f721e9ced997c417481f2c273ca.zip
Improved aoc script (was aocd)
Diffstat (limited to 'aoc')
-rwxr-xr-xaoc35
1 files changed, 35 insertions, 0 deletions
diff --git a/aoc b/aoc
new file mode 100755
index 0000000..56da404
--- /dev/null
+++ b/aoc
@@ -0,0 +1,35 @@
1#!/bin/sh
2
3# Set up a working environment for Advent of Code (https://adventofcode.com/).
4# Requires tmux, lynx, curl and a valid AOC_SESSION_COOKIE session cookie.
5
6# usage: aoc [yyyy nn]
7# If yyyy (year) and nn (day, with leading zero if single digit) are not
8# specified, the current year and day are used.
9
10editor="vi a.py"
11basedir="$HOME/src/aoc"
12lynx_cookie_file="$(mktemp)"
13clibrowser="lynx -cookie_file=$lynx_cookie_file"
14
15year="${1:-$(date +'%Y')}"
16day="${2:-$(date +'%d')}"
17daynozero="$(echo "$day" | sed 's/^0//')"
18
19cd "$basedir/$year/$day"
20
21# Download the puzzle input and save it to input.txt
22url="https://adventofcode.com/$year/day/$daynozero/input"
23curl "$url" -H "cookie: session=$AOC_SESSION_COOKIE" -o input.txt
24
25# Open a tmux session with lynx in its own windows, and an editor and a
26# terminal in split view.
27printf 'adventofcode.com\tFALSE\t/\tTRUE\t2079722976\tsession\t%s' \
28 "$AOC_SESSION_COOKIE" > "$lynx_cookie_file"
29url="https://adventofcode.com/$year/day/$daynozero"
30tmux new-session \; \
31 send-keys "$editor" C-m \; \
32 split-window -h \; \
33 select-pane -t 0 \; \
34 new-window \; \
35 send-keys "$clibrowser $url" C-m \;

Generated with cgit - Back to sebastiano.tronto.net