jira.plugin.zsh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. local open_cmd
  15. if [[ $(uname -s) == 'Darwin' ]]; then
  16. open_cmd='open'
  17. else
  18. open_cmd='xdg-open'
  19. fi
  20. if [ -f .jira-url ]; then
  21. jira_url=$(cat .jira-url)
  22. elif [ -f ~/.jira-url ]; then
  23. jira_url=$(cat ~/.jira-url)
  24. elif [[ "x$JIRA_URL" != "x" ]]; then
  25. jira_url=$JIRA_URL
  26. else
  27. echo "JIRA url is not specified anywhere."
  28. return 0
  29. fi
  30. if [ -z "$1" ]; then
  31. echo "Opening new issue"
  32. `open $jira_url/secure/CreateIssue!default.jspa`
  33. else
  34. echo "Opening issue #$1"
  35. if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
  36. $open_cmd "$jira_url/issues/$1"
  37. else
  38. $open_cmd "$jira_url/browse/$1"
  39. fi
  40. fi
  41. }
  42. alias jira='open_jira_issue'