Created
January 1, 2022 04:48
-
-
Save chrisgoffinet/ecf95edc9c974fdff9f3208f2d92c490 to your computer and use it in GitHub Desktop.
access clipboard using zsh + maccy
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
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