Skip to content

Instantly share code, notes, and snippets.

@roosto
Created September 2, 2020 13:16
Show Gist options
  • Save roosto/3a18e2466b058d7ee250793a1926743e to your computer and use it in GitHub Desktop.
Save roosto/3a18e2466b058d7ee250793a1926743e to your computer and use it in GitHub Desktop.
Filter/Modify contents of the macOS pasteboard using arbitrary commands
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