Skip to content

Instantly share code, notes, and snippets.

@dlnilsson
Last active February 11, 2025 08:18
Show Gist options
  • Save dlnilsson/31641841d3ec7c1102f06289c090f3a7 to your computer and use it in GitHub Desktop.
Save dlnilsson/31641841d3ec7c1102f06289c090f3a7 to your computer and use it in GitHub Desktop.
giphymd
2025-02-11.09-04-32.mp4
# 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 "![]($res)" | xsel --clipboard --input
clear
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment