Skip to content

Commit

Permalink
[scripts] ,linear-tickets: list and open linear tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Mar 30, 2024
1 parent 9ecfdab commit 1cc839f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions scripts/.local/bin/random/,linear-tickets
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# List and open linear tickets assigned to you
# https://developers.linear.app/docs
# https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference

set -e

tmpfile="/tmp/linear-tickets"

if [ "$(find "$tmpfile" -mmin -10 2>/dev/null)" = "" ]; then
printf "Fetching linear tickets...\r"
curl -sX POST \
-H "Content-Type: application/json" \
-H "Authorization: $LINEAR_TOKEN" \
-d '{"query": "query {user(id: \"'"$LINEAR_USER_ID"'\") {id organization { urlKey } name assignedIssues {nodes {identifier state {type} title}}}}"}' \
https://api.linear.app/graphql >"$tmpfile"
fi

format_issues() {
jq -r '.data.user.assignedIssues.nodes[]|"[\(.state.type)] \(.identifier) \(.title)"' <"$tmpfile"
}

urlkey="$(jq -r '.data.user.organization.urlKey' <"$tmpfile")"

{
format_issues | grep -E "^\[started"
format_issues | grep -E "^\[unstarted"
} | ,picker -m | cut -d' ' -f2 | xargs -I{} open "https://linear.app/$urlkey/issue/{}"

0 comments on commit 1cc839f

Please sign in to comment.