diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index 4d73d22c3..1cda6e719 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -314,3 +314,19 @@ source "${0:h:A}/music" # Spotify control function source "${0:h:A}/spotify" + +# Copy file to the macOS pasteboard +function pbfile() { + if [[ $# -ne 1 ]]; then + echo "Usage: pbfile " + 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" +}