Created
September 2, 2020 13:16
-
-
Save roosto/3a18e2466b058d7ee250793a1926743e to your computer and use it in GitHub Desktop.
Filter/Modify contents of the macOS pasteboard using arbitrary commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pbmunge { | |
if [[ "$1" ]] && echo "$1" | grep -q -e '^-h$' -e '^--help$' | |
then | |
echo 'Usage: pbmunge utility [util-arg ...]' | |
echo '' | |
echo "Filter (or munge) contents of the macOS pasteboard using \`utility'" | |
echo " \`utility' will be invoked with any supplied util-arg(s)" | |
echo '' | |
echo 'Example: increase the quote level of a plain text email' | |
echo "\$ pbmunge sed -e 's/^/> /g'" | |
return 0 | |
fi | |
if [[ $# -eq 0 ]] | |
then | |
echo 'pbmunge: error! expected at least one argument' 1>&2 | |
return 1 | |
fi | |
pbpaste | "$@" | pbcopy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment