Add usaco cat and copy commands

Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
2026-09-24 12:51:33 +01:00
co-authored by Claude Code
parent 0b2113f577
commit 26a9c969bd
3 changed files with 24 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
# usaco cat <name>
[[ $# -ge 1 ]] || usage
dir="$(find_problem "$1")"
cat "$dir/main.cpp"
+16
View File
@@ -0,0 +1,16 @@
# usaco copy <name> (alias: cp)
# Copies the problem's main.cpp to the clipboard.
# Wayland: wl-copy; X11: xclip/xsel; last resort OSC52 escape (works over SSH).
[[ $# -ge 1 ]] || usage
dir="$(find_problem "$1")"
if [[ -n ${WAYLAND_DISPLAY:-} ]] && command -v wl-copy >/dev/null 2>&1; then
wl-copy < "$dir/main.cpp"
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard < "$dir/main.cpp"
elif command -v xsel >/dev/null 2>&1; then
xsel -b --input < "$dir/main.cpp"
else
# OSC52: terminal-native clipboard, also works through SSH
base64 -w0 < "$dir/main.cpp" | printf '\e]52;c;%s\a' "$(cat)"
fi