Skip to content

Instantly share code, notes, and snippets.

@Kshitij09
Created September 22, 2022 15:09
Show Gist options
  • Save Kshitij09/fa719c38f3b5ea1d0cc1dec0844184fa to your computer and use it in GitHub Desktop.
Save Kshitij09/fa719c38f3b5ea1d0cc1dec0844184fa to your computer and use it in GitHub Desktop.
Utility shell function to perform common operations around Jira Ticket URLs. Currently supports macOS only
function sjira() {
local __usage="
Usage: sjira GROW-3599 [-poc]
Options:
-p, --print Print genereated URL
-o, --open Open generated URL in browser (Default)
-c, --copy Copy generated URL to clipboard
"
if [ "$#" -lt 1 ]; then
echo $__usage
return 126;
fi
local ticket=$(echo $1 | sed -r 's/([A-Za-z]+)-?([0-9]+)/\1-\2/')
local url="https://example.atlassian.net/browse/$ticket"
opt=${2:-"-o"}
case $opt in
-p|--print)
echo $url
;;
-o|--open)
open $url
;;
-c|--copy)
echo $url | pbcopy
;;
*)
echo "idk ¯\_(ツ)_/¯"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment