diff options
| author | 0xHouss <67522466+0xHouss@users.noreply.github.com> | 2025-08-16 20:31:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-16 21:31:40 +0200 |
| commit | 736632228a5f39573a15f4533b7672851f30bbe6 (patch) | |
| tree | a85c87b22d4ef66367b38242c9f37ace43dc93ae /plugins/copyfile | |
| parent | 7504f22a0ce649ab577a6232f2a673ea98d773a6 (diff) | |
| download | zsh-736632228a5f39573a15f4533b7672851f30bbe6.tar.gz zsh-736632228a5f39573a15f4533b7672851f30bbe6.tar.bz2 zsh-736632228a5f39573a15f4533b7672851f30bbe6.zip | |
feat(copyfile): add error handling (#13248)
Diffstat (limited to 'plugins/copyfile')
| -rw-r--r-- | plugins/copyfile/copyfile.plugin.zsh | 14 |
1 files changed, 13 insertions, 1 deletions
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 <file> +# 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."} } |
