- Install Jira CLI, generate the API token and follow the initiation process. Make sure you can see a list of issues by using
jira issue list
. - Install fzf and setup some default configs if you like.
- Put this code below into your
.zshrc
(I'm not sure about.bashrc
, did not test it.
_fzf_complete_git() {
ARGS="$@"
CODE="$(echo $ARGS | sed 's/git checkout -b //g')"
if [[ $CODE == "" ]]; then
ME="-a$(jira me)"
PROJECT_QUERY="AND project IS NOT EMPTY"
else
ME=""
PROJECT_QUERY="AND project IN ($CODE)"
fi
local tasks
tasks=$(jira issue list --plain --no-headers --columns key,summary $ME -q "status NOT IN (Done, Dismissed, Released, 'In Progress', 'Ready for release') $PROJECT_QUERY")
if [[ $ARGS == 'git checkout -b'* ]]; then
_fzf_complete --ansi --reverse --multi --prompt="fzf> " -- "git checkout -b " < <(
echo $tasks | sed 's/[[:space:]]/-/g' | tr -dc '[:alnum:]-\n'
)
fi
}
- Source the
.zshrc
and you can use.
- Type the git command:
git checkout -b CODE **
then pressTab
. - The
CODE
is the prefix of your ticket code. Usually they are in formatABC-123
. - If the
CODE
is omitted, it will try to search only tasks assigned to you. - If you already changed your trigger to
~~
, replace**
with~~
.