ao-mud is a spellbook of well-commented atomic bash scripts that each do one thing. we are building semantic building blocks for an autonomously-evolving digital spellcasting language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.2 KiB

#!/bin/sh
# This spell copies the text file at the specified path to the clipboard.
# It takes one argument, the path to the text file.
if [ ! -f "$1" ]; then
echo "That file does not exist."
exit 1
fi
# Check if the `pbcopy` command is available (only on macOS). If it is, use it to copy the contents of the file to the clipboard.
if command -v pbcopy >/dev/null 2>&1; then
pbcopy < "$1"
# If `pbcopy` is not available, check if the `xsel` command is available (only on some Unix-based systems). If it is, use it to copy the contents of the file to the clipboard.
elif command -v xsel >/dev/null 2>&1; then
xsel --clipboard --input < "$1"
# If neither `pbcopy` nor `xsel` is available, check if the `xclip` command is available (only on some Unix-based systems). If it is, use it to copy the contents of the file to the clipboard.
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard < "$1"
# If none of the above commands are available, print an error message.
else
echo "Your spell fizzles. No clipboard utilities are available on this system. Please install xsel, xclip, or pbcopy (for mac)" >&2
exit 1
fi
echo "Copied $1 to your clipboard."