├── demo.gif
├── README.md
├── LICENSE
└── gh-star
/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keidarcy/gh-star/HEAD/demo.gif
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # `gh star` GitHub CLI extension
2 |
3 | [GitHub CLI](https://github.com/cli/cli) extension to fuzzy search from current account _all_ starred repo using [fzf](https://github.com/junegunn/fzf#readme).
4 |
5 | ## Installation
6 | ```
7 | gh extension install keidarcy/gh-star
8 | ```
9 |
10 | ## Usage
11 | ```
12 | Usage: gh star [options]
13 |
14 | GitHub CLI extension to fuzzy search starred repo using fzf.
15 |
16 | Options:
17 | -w, --watch Open a repository in the browser
18 | -h, --help Show this help message
19 | ```
20 |
21 |
22 | Expand for Demo
23 |
24 | 
25 |
26 |
27 | Displays an interactive starred repo picker and open in browser.
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/gh-star:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 |
4 | # fuzzy finder starred repos
5 |
6 | _help() {
7 | echo "Usage: gh star [options]
8 |
9 | GitHub CLI extension to fuzzy search starred repo using fzf.
10 |
11 | Options:
12 | -w, --watch Open a repository in the browser
13 | -h, --help Show this help message"
14 | }
15 |
16 | QUERY='
17 | query FetchStarredRepo($endCursor: String) {
18 | viewer {
19 | login
20 | starredRepositories(first: 100, after: $endCursor) {
21 | totalCount
22 | pageInfo {
23 | hasNextPage
24 | endCursor
25 | }
26 | edges {
27 | node {
28 | description
29 | nameWithOwner
30 | }
31 | }
32 | }
33 | }
34 | }
35 | '
36 |
37 | TEMPLATE='
38 | {{- range $repo := .data.viewer.starredRepositories.edges -}}
39 | {{ "name" | color "yellow" }}
40 | {{- printf ": %s - " $repo.node.nameWithOwner -}}
41 | {{ "description" | color "blue" }}
42 | {{- printf ": %v\n" $repo.node.description -}}
43 | {{- end -}}
44 | '
45 |
46 | case "$1" in
47 | -h|--help)
48 | _help
49 | exit 0
50 | ;;
51 | -w|--watch)
52 | exec gh api graphql -f query="${QUERY}" --paginate --template="${TEMPLATE}" --cache 10m \
53 | | fzf --ansi --header 'My favorite star this time is...' --header-lines=0 --height 80% --preview 'gh repo view {+2}' \
54 | | cut -d " " -f 2 \
55 | | xargs gh repo view -w \
56 | ;;
57 | *)
58 | exec gh api graphql -f query="${QUERY}" --paginate --template="${TEMPLATE}" --cache 10m \
59 | | fzf --ansi --header 'My favorite star this time is...' --header-lines=0 --height 80% --preview 'gh repo view {+2}' \
60 | | xargs \
61 | | awk -v a="Detail in https://github.com/" -F " " '{print a b $2 "."}'
62 | esac
63 |
64 | # exit 1 if fzf not installed
65 | if ! command -v fzf > /dev/null; then
66 | echo "Error: Install \`fzf\` to use this command." >&2
67 | exit 1
68 | fi
69 |
--------------------------------------------------------------------------------