If I'm using zsh and currently on a git branch ABC-12312 which corresponds to a JIRA ticket and endpoint, how can I get to the endpoint from the CLI, without oh-my-zsh addon?


After trial and error, this seems to be the minimalist script, using the built-in vcs_info command

I could be completely wrong, but I believe that it:

  1. requires / enables vcs_info
  2. styles future vcs_info return / replacement (try removing the second line and you will see the url change)
  3. creates a function jira (where $0 is the word jira, $1 would be the next word, but we're using $vcs_info_msg_0_) that calls open with whichever default application handles the string format. vcs_info queries the git branch and registers the variable vcs_info_msg_0_ for future usage

autoload -Uz vcs_info
zstyle ':vcs_info:git:*' formats '%b'

jira () {
  open "http://jira.corp.asdf.com/browse/$vcs_info_msg_0_"

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.