Skip to content

Instantly share code, notes, and snippets.

@kuntau
Created June 29, 2024 18:18
Show Gist options
  • Save kuntau/6d82ea5e653c4833ec32c1c7d658dffa to your computer and use it in GitHub Desktop.
Save kuntau/6d82ea5e653c4833ec32c1c7d658dffa to your computer and use it in GitHub Desktop.
Search code on github with fzf
# uses 'gh', 'fzf' and 'bat'
gh search code $'#compdef fzf' \
--filename '_fzf' \
--json repository,path \
--jq '.[] | [.repository.nameWithOwner, .path] | @tsv' |
fzf --delimiter '\t' --with-nth 1 \
--preview 'gh api --cache 10m repos/{1}/contents/{2} \
--jq .content | base64 --decode | bat --language zsh --number' \
--preview-window 'nohidden:right:wrap:75%' \
--bind 'ctrl-b:execute-silent:gh browse --repo {1} {2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment