Skip to content

Instantly share code, notes, and snippets.

@blakef
Created September 26, 2018 09:20
Show Gist options
  • Save blakef/8c6345e7b257f967cddca1a04a059475 to your computer and use it in GitHub Desktop.
Save blakef/8c6345e7b257f967cddca1a04a059475 to your computer and use it in GitHub Desktop.
Open to a jira ticket looking at: argument, clipboard or current repository
#!/bin/bash
URL=https://<megacorp>.atlassian.net/browse/
TICKET_PREFIX=FOO
function validTicket() {
FOUND=`echo "$1" | sed 's/.*\($TICKET_PREFIX-[0-9]\+\).*/\1/Ig' | tr [:lower:] [:upper:]`
if [[ "$FOUND" == WYN* ]]; then
open "$URL$FOUND"
exit 0
fi
}
clipboard=`pbpaste`
git=`git rev-parse --abbrev-ref HEAD 2>/dev/null`
validTicket "$1"
validTicket "$clipboard"
validTicket "$git"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment