Files
ohmyzsh/plugins/copyfile/copyfile.plugin.zsh
0xHouss 736632228a
Some checks failed
CI / Run tests (push) Has been cancelled
Update dependencies / Check for updates (push) Has been cancelled
feat(copyfile): add error handling (#13248)
2025-08-16 21:31:40 +02:00

20 lines
369 B
Bash

# Copies the contents of a given file to the system or X Windows clipboard
#
# Usage: copyfile <file>
function copyfile {
emulate -L zsh
if [[ -z "$1" ]]; then
echo "Usage: copyfile <file>"
return 1
fi
if [[ ! -f "$1" ]]; then
echo "Error: '$1' is not a valid file."
return 1
fi
clipcopy $1
echo ${(%):-"%B$1%b copied to clipboard."}
}