Last active
February 11, 2025 08:18
-
-
Save dlnilsson/31641841d3ec7c1102f06289c090f3a7 to your computer and use it in GitHub Desktop.
giphymd
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
# giphymd, go install github.com/peterhellberg/giphy/cmd/giphy | |
# Set environment variables | |
# GIPHY_API_KEY=YourToken # https://developers.giphy.com/docs/api#quick-start-guide | |
# GIPHY_LIMIT=6 | |
# See: https://github.com/peterhellberg/giphy | |
giphymd() { | |
local query="$*" | |
if [[ -z "$query" ]]; then | |
echo "Usage: giphymd <search-term>" | |
return 1 | |
fi | |
local -a items=("${(@f)$(giphy search "$query")}") | |
local res | |
res=$(printf '%s\n' "${items[@]}" | fzf \ | |
--preview-window 'up,85%,border-bottom,+{2}+3/3,~3' \ | |
--bind 'ctrl-y:execute-silent(echo {})+abort' \ | |
--preview="kitty icat --clear --transfer-mode=memory --stdin=no \ | |
--place=\${FZF_PREVIEW_COLUMNS}x\${FZF_PREVIEW_LINES}@0x0 {}") | |
echo "" | xsel --clipboard --input | |
clear | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment