Add usaco cat and copy commands
Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user