mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
feat(copyfile): add error handling (#13248)
This commit is contained in:
parent
7504f22a0c
commit
736632228a
1 changed files with 13 additions and 1 deletions
|
|
@ -1,7 +1,19 @@
|
||||||
# Copies the contents of a given file to the system or X Windows clipboard
|
# Copies the contents of a given file to the system or X Windows clipboard
|
||||||
#
|
#
|
||||||
# copyfile <file>
|
# Usage: copyfile <file>
|
||||||
function copyfile {
|
function copyfile {
|
||||||
emulate -L zsh
|
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
|
clipcopy $1
|
||||||
|
echo ${(%):-"%B$1%b copied to clipboard."}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue