ohmyzsh/plugins/pbfile/pbfile.plugin.zsh
Anton 53007b51f7
pbfile plugin
Copies files to the macOS pasteboard for pasting with Cmd+V in Finder, messengers, and other apps.
2025-07-09 22:55:07 +02:00

19 lines
392 B
Bash

# Check if running on macOS
if [[ "$OSTYPE" != darwin* ]]; then
return
fi
function pbfile() {
if [[ $# -ne 1 ]]; then
echo "Usage: pbfile <file>"
return 1
fi
if [[ ! -e "$1" ]]; then
echo "File not found: $1"
return 1
fi
osascript -e "tell application \"Finder\" to set the clipboard to (POSIX file \"$(realpath "$1")\")"
echo "Copied $1 to pasteboard"
}