diff options
author | Oliver Ford | 2020-10-02 22:21:41 +0100 |
---|---|---|
committer | Oliver Ford | 2020-10-03 01:21:16 +0100 |
commit | 2f8ead04d69782cacbfe5720853abfc5a179b288 (patch) | |
tree | 1380dd685f6a20af0a9838489c62c6186332aaf5 | |
parent | 384137f60e1c36582e0f9714c42bf623a2df3d0b (diff) | |
download | aur-2f8ead04d69782cacbfe5720853abfc5a179b288.tar.gz |
Add basic issues implementation
-rw-r--r-- | README.md | 18 | ||||
-rwxr-xr-x | rofi-gh-issues | 38 |
2 files changed, 56 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 000000000000..d8ccecefefcb --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# rofi-gh + +Allows you to get GitHub in [rofi](//github.com/davatorium/rofi). + + - List issues in your repositories and open them (`rofi-gh-issues`) + - Looking for something else? Issues & PRs welcome :) + +## Usage + +Ensure the scripts you wish to use are somewhere on your `$PATH` (for example, `/usr/local/bin/rofi-gh-issues`) and run `rofi -show '<prompt>:<script>'` (`rofi -show 'GH:rofi-gh-issues'`). + +### rofi-gh-issues + +This one was my initial motivation for `rofi-gh`, so that I could sit down in the mood to work on something, but with nothing particular in mind, and see what issues I have open in my repositories. For that reason, the default (and presently only) query is: + + - [`user:@me is:open`](//github.com/issues?q=user%3A%40me+is%3Aopen) (default) + +But I'm certainly open to adding configuration if you have other use-cases/desires (open an issue or PR). diff --git a/rofi-gh-issues b/rofi-gh-issues new file mode 100755 index 000000000000..fa717058108c --- /dev/null +++ b/rofi-gh-issues @@ -0,0 +1,38 @@ +#!/bin/bash +set -Ee +set -u +set -o pipefail + +issuesjson="${XDG_CACHE_HOME:-$HOME/.cache}/rofi-gh-issues/issues.json" +mkdir -p "$(dirname "$issuesjson")" + +initial_call_list() { + gh api search/issues -X GET -f q='user:@me is:open' \ + | jq '.items | map({url:.html_url, display:("[" + (.repository_url | split("/"))[-1] + "] " + .title)})' \ + | tee "$issuesjson" \ + | jq -r 'map(.display)[]' \ + ; + return 0 +} + +selected_entry() { + selection="$1" + jq -r ".[] | select(.display==\"$selection\").url" "$issuesjson" \ + | xargs xdg-open \ + ; + return 0 +} + +case "$ROFI_RETV" in + 0) + initial_call_list + exit "$?" + ;; + 1) + selected_entry "$1" + exit "$?" + ;; + *) + exit 2 + ;; +esac |