Skip to content

Instantly share code, notes, and snippets.

@chrisgoffinet
Created January 1, 2022 04:48
Show Gist options
  • Save chrisgoffinet/ecf95edc9c974fdff9f3208f2d92c490 to your computer and use it in GitHub Desktop.
Save chrisgoffinet/ecf95edc9c974fdff9f3208f2d92c490 to your computer and use it in GitHub Desktop.
access clipboard using zsh + maccy
fcc() {
DB=~/Library/Containers/org.p0deje.Maccy/Data/Library/Application\ Support/Maccy/Storage.sqlite
SQL="select distinct ZVALUE
from ZHISTORYITEMCONTENT
where ZTYPE IN ('public.text','public.utf8-plain-text')
order by Z_PK desc"
if ! [ -r "$DB" ]; then
MSG='Maccy database not found. "brew cask install maccy" to install Maccy.'
echo "$MSG"
exit 1
fi
SEP=$(head -128 /dev/urandom | shasum)
SEP="${SEP:0:8}"
target=$(sqlite3 -newline "$SEP" "$DB" "$SQL" | perl -pe "s/$SEP/\\x0/g" | \
fzf-tmux "$@" -- --read0 --layout=reverse --multi --prompt='Maccy> ' --tiebreak=index) || return
pbcopy <<<"$target"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment