mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
Copies files to the macOS pasteboard for pasting with Cmd+V in Finder, messengers, and other apps.
19 lines
392 B
Bash
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"
|
|
}
|