]> git.rmz.io Git - dotfiles.git/blob - zsh/plugins/jira/jira.plugin.zsh
b91f93c9565620f53094880cef5bc0469ab3250f
[dotfiles.git] / zsh / plugins / jira / jira.plugin.zsh
1 # To use: add a .jira-url file in the base of your project
2 # You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
3 # .jira-url in the current directory takes precedence
4 #
5 # If you use Rapid Board, set:
6 #JIRA_RAPID_BOARD="yes"
7 # in you .zshrc
8 #
9 # Setup: cd to/my/project
10 # echo "https://name.jira.com" >> .jira-url
11 # Usage: jira # opens a new issue
12 # jira ABC-123 # Opens an existing issue
13 open_jira_issue () {
14 if [ -f .jira-url ]; then
15 jira_url=$(cat .jira-url)
16 elif [ -f ~/.jira-url ]; then
17 jira_url=$(cat ~/.jira-url)
18 elif [[ "x$JIRA_URL" != "x" ]]; then
19 jira_url=$JIRA_URL
20 else
21 echo "JIRA url is not specified anywhere."
22 return 0
23 fi
24
25 if [ -z "$1" ]; then
26 echo "Opening new issue"
27 `open $jira_url/secure/CreateIssue!default.jspa`
28 else
29 echo "Opening issue #$1"
30 if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
31 `open $jira_url/issues/$1`
32 else
33 `open $jira_url/browse/$1`
34 fi
35 fi
36 }
37
38 alias jira='open_jira_issue'