Add usaco cat and copy commands
Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
# usaco cat <name>
|
||||
[[ $# -ge 1 ]] || usage
|
||||
dir="$(find_problem "$1")"
|
||||
cat "$dir/main.cpp"
|
||||
@@ -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
|
||||
@@ -11,6 +11,8 @@
|
||||
# usaco skip <name> Move solving/<name> -> skipped/<name>
|
||||
# usaco io <name> [io-name] Show the problem's io name, or set it: renames <old>.in/.out
|
||||
# and rewires STDIO("...") in main.cpp (adds it if missing)
|
||||
# usaco cat <name> Print the problem's main.cpp to stdout (pipeable)
|
||||
# usaco copy <name> Copy the problem's main.cpp to the clipboard (alias: cp)
|
||||
# usaco vim <name> Open the problem's main.cpp in $EDITOR (aliases: edit, e)
|
||||
# usaco open <name> Open the problem's saved URL in a browser
|
||||
# usaco list List problems by status
|
||||
@@ -47,6 +49,8 @@ case "$cmd" in
|
||||
undo|u) cmd=undo ;;
|
||||
skip|sk) cmd=skip ;;
|
||||
io) cmd=io ;;
|
||||
cat) cmd=cat ;;
|
||||
copy|cp) cmd=copy ;;
|
||||
vim|edit|e) cmd=edit ;;
|
||||
open|o) cmd=open ;;
|
||||
list|l|ls) cmd=list ;;
|
||||
|
||||
Reference in New Issue
Block a user