Last active
January 13, 2021 08:10
-
-
Save philib/34ca005328b9e5d1088afb478ea489d8 to your computer and use it in GitHub Desktop.
fzf jira - fuzzy find KNUTH numbers
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
| # Fuzzy find jira ticket numbers | |
| # https://github.com/keepcosmos/terjira required | |
| _jira_ticket() { | |
| is_in_git_repo || return | |
| local USER='PSH' | |
| local JIRA_TICKET_REGEX='KNUTH-\w*' | |
| jira issue jql "status = 'In Implementation' AND assignee = $USER AND type in ('Technical Task', 'Sub Bug')" | grep $JIRA_TICKET_REGEX | sed 's/│//g' | sed 's/In Implementation//' | fzf-down --layout reverse --info inline --preview "echo {} | grep -o '$JIRA_TICKET_REGEX' | xargs jira issue" --preview-window down:80% | grep -o $JIRA_TICKET_REGEX | |
| } | |
| is_in_git_repo() { | |
| git rev-parse HEAD > /dev/null 2>&1 | |
| } | |
| fzf-down() { | |
| fzf --multi --ansi --reverse --keep-right --height 100% "$@" --border | |
| } | |
| join-lines() { | |
| local item | |
| while read item; do | |
| echo -n "${(q)item}" | |
| done | |
| } | |
| fzf-jira-ticket-widget() { | |
| local result=$(_jira_ticket | join-lines) | |
| zle reset-prompt | |
| LBUFFER+=$result | |
| } | |
| zle -N fzf-jira-ticket-widget | |
| bindkey '^j^k' fzf-jira-ticket-widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment