Last active
September 9, 2021 12:09
-
-
Save sheepla/d877def8ba4aaf059649c2ca4798b71d to your computer and use it in GitHub Desktop.
GitHubリポジトリを検索して、fzfで選択したリポジトリをデフォルトのブラウザで開く.sh
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
| #!/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