https://github.com/chee/pbv
fork of chbrown's macos-pasteboard that can list out the types
https://github.com/chee/pbv
Last synced: about 1 month ago
JSON representation
fork of chbrown's macos-pasteboard that can list out the types
- Host: GitHub
- URL: https://github.com/chee/pbv
- Owner: chee
- Created: 2022-10-23T20:14:14.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T02:10:51.000Z (over 3 years ago)
- Last Synced: 2025-03-15T15:40:48.345Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# macos-pasteboard
fork of [chbrown's macos-pasteboard](https://github.com/chbrown/macos-pasteboard/)
Like macOS's built-in `pbpaste` but more flexible and raw.
## Install
```sh
git clone https://github.com/chbrown/macos-pasteboard
cd macos-pasteboard
make install
```
## Example
In a web browser (I'm using Safari), highlight and copy the "macos-pasteboard" heading at the top of this README.
`pbv --help` lists the types supported by the current contents of the clipboard. The available types depend not only on the type of object you copied, but also on which program you copied it within.
```console
$ pbv --help
Usage: pbv [-h|--help]
pbv [dataType [dataType [...]]] [-s|--stream]
Read contents of pasteboard as 'dataType'. If multiple types are specified,
tries each from left to right, stopping at first success. If omitted,
defaults to 'public.utf8-plain-text'.
Options:
-h|--help Show this help and exit
-s|--stream Start an infinite loop polling the Pasteboard 'changeCount',
running as usual whenever it changes
Available types for the 'Apple CFPasteboard general' pasteboard:
dyn.ah62d4rv4gu8y63n2nuuhg5pbsm4ca6dbsr4gnkduqf31k3pcr7u1e3basv61a3k
NeXT smart paste pasteboard type
com.apple.webarchive
Apple Web Archive pasteboard type
public.rtf
NeXT Rich Text Format v1.0 pasteboard type
public.html
Apple HTML pasteboard type
public.utf8-plain-text
NSStringPboardType
com.apple.WebKit.custom-pasteboard-data
public.utf16-external-plain-text
CorePasteboardFlavorType 0x75743136
dyn.ah62d4rv4gk81n65yru
CorePasteboardFlavorType 0x7573746C
com.apple.traditional-mac-plain-text
CorePasteboardFlavorType 0x54455854
dyn.ah62d4rv4gk81g7d3ru
CorePasteboardFlavorType 0x7374796C
```
If you don't pass a data type, `pbv` will default to outputting the plain text version (the `public.utf8-plain-text` type):
```console
$ pbv
macos-pasteboard
```
But in this example we want the HTML version of what we copied:
```console
$ pbv public.html
macos-pasteboard
```
Using [tidy](http://www.html-tidy.org/),
[xmlstarlet](http://xmlstar.sourceforge.net/), and
[kramdown](https://kramdown.gettalong.org/),
we can convert this to Markdown without too much pain:
```console
$ pbv public.html \
| tidy -quiet --show-warnings no -asxml -i -w 0 --quote-nbsp no \
| xmlstarlet ed -d //@id -d //@class -d //@rel -d //@style -d //@target -d //_:br -r //_:u -v span \
| xmlstarlet sel -i -t -c '/_:html/_:body/node()' \
| sed -e 's/ xmlns="[^[:space:]]*"//g' \
| kramdown -i html -o remove_html_tags,kramdown --line-width 9999 --remove-span-html-tags
# macos-pasteboard
```
## License
Copyright © 2016–2020 Christopher Brown.
[MIT Licensed](https://chbrown.github.io/licenses/MIT/#2016-2020).