Skip to content

Instantly share code, notes, and snippets.

@sheepla
Last active September 9, 2021 12:09
Show Gist options
  • Select an option

  • Save sheepla/d877def8ba4aaf059649c2ca4798b71d to your computer and use it in GitHub Desktop.

Select an option

Save sheepla/d877def8ba4aaf059649c2ca4798b71d to your computer and use it in GitHub Desktop.
GitHubリポジトリを検索して、fzfで選択したリポジトリをデフォルトのブラウザで開く.sh
#!/bin/sh
# gh-fzopen -- search GitHub repositories
# and open the one selected with fzf in your browser
#
# Usage:
# gh-fzopen KEYWORD...
#
# Dependences:
# - curl
# - jq
# - fzf
# - xdg-urils (xdg-open command)
#
_encode() {
echo -n "${*}" | od -tx1 -An | tr ' ' % | tr -d \\n
}
query="$(_encode "${*})"
curl \
--silent \
--header "Accept: application/vnd.github.v3+json" \
"https://api.github.com/search/repositories?q=${query}" \
| jq -r '.items[].full_name' \
| fzf --multi \
| xargs -I@ -- xdg-open "https://github.com/@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment