mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
pbfile plugin
Copies files to the macOS pasteboard for pasting with Cmd+V in Finder, messengers, and other apps.
This commit is contained in:
parent
3e7ef0182f
commit
53007b51f7
2 changed files with 39 additions and 0 deletions
20
plugins/pbfile/README.md
Normal file
20
plugins/pbfile/README.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# pbfile plugin
|
||||
|
||||
Copies files to the macOS pasteboard for pasting with Cmd+V in Finder, messengers, and other apps.
|
||||
|
||||
To use it, add `pbfile` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... pbfile)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- `pbfile <file>`: copies the given file to the pasteboard for pasting as an attachment.
|
||||
|
||||
## Examples
|
||||
|
||||
```zsh
|
||||
pbfile document.pdf
|
||||
pbfile config.json
|
||||
```
|
||||
19
plugins/pbfile/pbfile.plugin.zsh
Normal file
19
plugins/pbfile/pbfile.plugin.zsh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# 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"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue