2015-08-18 04:53:45 +02:00
|
|
|
# Copies the contents of a given file to the system or X Windows clipboard
|
|
|
|
|
#
|
2025-08-16 21:31:40 +02:00
|
|
|
# Usage: copyfile <file>
|
2013-04-08 22:32:00 +02:00
|
|
|
function copyfile {
|
2015-08-18 04:53:45 +02:00
|
|
|
emulate -L zsh
|
2025-08-16 21:31:40 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2015-08-18 04:53:45 +02:00
|
|
|
clipcopy $1
|
2025-08-16 21:31:40 +02:00
|
|
|
echo ${(%):-"%B$1%b copied to clipboard."}
|
2013-04-08 22:32:00 +02:00
|
|
|
}
|