diff --git a/plugins/macos/README.md b/plugins/macos/README.md index ccc4331e5..ac6ca0b86 100644 --- a/plugins/macos/README.md +++ b/plugins/macos/README.md @@ -39,6 +39,7 @@ plugins=(... macos) | `rmdsstore` | Remove .DS_Store files recursively in a directory | | `btrestart` | Restart the Bluetooth daemon | | `freespace` | Erases purgeable disk space with 0s on the selected disk | +| `pbfile` | Copy the file reference to the macOS pasteboard | ## Acknowledgements 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" +}