jira.plugin.zsh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. if [ -z "$1" ]; then
  25. echo "Opening new issue"
  26. `open $jira_url/secure/CreateIssue!default.jspa`
  27. else
  28. echo "Opening issue #$1"
  29. if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
  30. `open $jira_url/issues/$1`
  31. else
  32. `open $jira_url/browse/$1`
  33. fi
  34. fi
  35. }
  36. alias jira='open_jira_issue'