From 736632228a5f39573a15f4533b7672851f30bbe6 Mon Sep 17 00:00:00 2001 From: 0xHouss <67522466+0xHouss@users.noreply.github.com> Date: Sat, 16 Aug 2025 20:31:40 +0100 Subject: [PATCH] feat(copyfile): add error handling (#13248) --- plugins/copyfile/copyfile.plugin.zsh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/copyfile/copyfile.plugin.zsh b/plugins/copyfile/copyfile.plugin.zsh index f4eca5acf..3281410e5 100644 --- a/plugins/copyfile/copyfile.plugin.zsh +++ b/plugins/copyfile/copyfile.plugin.zsh @@ -1,7 +1,19 @@ # Copies the contents of a given file to the system or X Windows clipboard # -# copyfile +# Usage: copyfile function copyfile { emulate -L zsh + + if [[ -z "$1" ]]; then + echo "Usage: copyfile " + 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."} }