From b7c2682ca0054b565e79fe590dd0398020406f44 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 17 Jul 2025 22:01:04 +0200 Subject: [PATCH] pbfile function in macos.plugin.zsh --- plugins/macos/macos.plugin.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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" +}